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.

Multiple find() array parameters

Hi,

how can i set an array to the find function? The parameter $wantedUsersId, is an array of id's -> 1,2,3,4,5,....

$users = Users::find($wantedUsersId);

Thx

Stefan

edited Nov '15

I think it's supported since 2.0.4

https://blog.phalconphp.com/post/phalcon-2-0-4-released

https://docs.phalconphp.com/en/latest/reference/models.html

$wantedUsersId = [[0] => 35, [2] => 78]; //keys must be numbered from zero:
$users = Users::find(
    array(
        'id IN ({ids:array})',
        'bind' => array(
            'ids' => $wantedUsersId
        )
    )
);


17.3k
edited Nov '15

Hello Jimmy,

Yes it works :-))

This also works:

  $users = Users::query()
           ->inWhere('id', $blackbookUsersId)
           ->execute();

Rgds

Stefan