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

Counting models doesnt work

When trying to count some data using this way:
https://docs.phalcon.io/en/latest/reference/models.html#generating-calculations

User::count(array('name' => 'Foo'));

It always returns the full range of users so I get x instead of 1.
For me its weird because I'm sure it worked.

edited Jul '15

Where type : User::count("name = 'Foo' ");



7.0k
edited Jul '15

Hmm, could work but I'll need some protection against SQL-Injection.

It works now using a similar method like this, but I still would use my way.. when it works.

$count = User::count(array(
    'name > ?0'
    'bind' => array('Foo')
));

Hmm, guess I'm not the only one trying to use associative arrays as condition :] https://forum.phalcon.io/discussion/7821/modelfind-modelfindfirst-conditions-from-associative-array