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

$and in Mongodb

Hi,

Can you please suggest me whether the below syntax correct ? "$and" is not working in Mongodb Query.

            $general = [[ '$and' => [[ "user_id" => $input['user_id']],[ "type" => $type ]]]];
            $object = Profile::findFirst($general);

Please suggest me on the same.

Raja K



1.6k

I'm not much experienced in Mongo, but don't you need just this?

$general = [[ 'user_id' => $input['user_id'], 'type' => $type ]];
$object = Profile::findFirst($general);


13.2k

Hi,

Thanks. Let me test it again and get back to you .

Raja K