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

How to find by 2 parameter id in database

$iduser = $this->request->get('iduser'); $idmenu = $this->request->get('idmenu'); $data_menu = User::findFirstById($iduser,$idmenu);



6.8k
Accepted
answer
edited Aug '20

You need to pass array with SQL condition

$invoice = Invoices::findFirst([
    'id_user = ?0 AND id_menu = ?1',
    'bind' => [$iduser, $idmenu],
]);

or

$invoice = Invoices::findFirst([
    'id_user = :iduser: AND id_menu = :idmenu:',
    'bind' => ['iduser' => $iduser, 'idmenu' => $idmenu],
]);

More examples: https://docs.phalcon.io/4.0/en/db-models#findfirst