We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

pagination passing data

I am fetching all records having flag =1 from contacts table...

$flag=1;
$contacts = Contacts::find('flag="'.$flag.'"');

$paginator = new Phalcon\Paginator\Adapter\Model(array(
"data" => $contacts,    //Data to paginate
"limit" => 30,           //Rows per page
"page" => $numberPage   //Active page
));

Now I want to fetch information from different table nameas mailcontacts having flag=1; $mail_contacts = MailContacts::find('flag="'.$flag.'"'); And Want to pass that mail_contacts data to contacts. Will it be possible in phalcon so that paginaion along with reset of the things should work.



51.1k

If you have a relations between Contacts and MailContacts you can use:

foreach ($paginator->getPaginate()->items as $contact)  {
    echo $contact->getName();
    foreach ($contact->getMailsContacts(["$flag = ".$contact->getFlag()]) as $mc) {
       /// echo something ?
    }
}