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 & mongodb - How to do findFirstBy syntax

Hi,

Can you please suggest me the syntax for Module::findFirstbyId ? in mongodo collection ?

Thanks, Raja K



13.2k

Hi,

I had found the solution.

use  \MongoId as MongoId;
$id =  new MongoId($input['id']);
$params = [ [ '_id' => $id ]];
$object = Department::findFirst($params);

Raja k