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

PHALCON Model Find By Resultset

Is it possible in PHALCON to fetch all rows base on the resultset object? My goal is to fetch all User's data in User table base on the user assigned entityID/s.

I don't want to extract my $allowedEntity object into array so that I can save execution time. I need to do for loop to convert my object into array so I prefer passing the whole object into the model finder.

I tried hydration but it didn't work.

$allowedEntity= $this->userallowedEntity();

Pass my $allowedEntity resultset in the model

if($allowedEntity) { $user = User::find(); }

Yea, first argument is condition. Just write proper condition like "userId = :userId:", nothing fancy:

User::find([
    "userId = :userId:",
    "bind" => [
        "userId" => $allowedEntity->id
])

My id will be a set of unique ID's, by just assigning directly $alloweEntity->id will that consider all the ID's that was fetched?

No, then you need to change it to:

$ids = [];
foreach($allowedEntity as $entity) {
    $ids[] = $entity->id;
}
$result = User::find([
    "userId IN ({ids:array})",
   "bind" => [
       "ids" => $ids
    ]
]);

There is no way to simply pass a ResultSet object to find(). You'll have to create an array of entity ids. You can save a little bit of computation time by changing the hydration mode of the from Records to arrays.

Yea dylan good point. Then you could just for example array_walk