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 count() with parameters does not work

Hi to all,

I notice that MongoDB ODM count does not work with parameters. You can read it here: https://docs.phalcon.io/en/latest/reference/odm.html

You see, regardless of the parameter I set, say,


It will disregard that and give the complete list instead.

My question is, am I doing it wrong? Because the documentation doesn't tell much, quite honestly, which needs to improve. If I am not doing it wrong, then what went wrong? The code is pretty much like this:


Looking forward for some clarifications.

Thanks a lot,

edited May '16


In ODM your code must be something like this:

CollectionModel::count([ 'conditions' => [ 'field' => 'value_to_check ] ]);


Thanks for the reply.

I have not continued to use this one though, instead, I used MongoCollection of PHP primarily because the table being referenced is not definite. There's a count method with it as well so I used it instead.

Alternatively, for such the same case I have noted above, a command using execute() under Mongo seems to work as well.

Still, I appreciate for giving time to reply regarding my question. Thanks a lot!