Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.4k
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