Yii Count(Cdbcriteria) With Limi

Simple question, why when I set


$oCriteria->limit =10


it’s not used in


Here we will get more then 10 (240 for example) and our $oCriteria->limit is not used. I know that it’s stupid enought but if I want get all entries (count). I don’t want to use pagination at all, I want simple limit the count by criteria.

Why you don’t use findAll before and then use count?

Why don’t You do count before setting limit. Something like:

$allRecords = Post::model()->count($oCriteria);

$oCriteria->limit =10;

$count = Post::model()->count($oCriteria);

That way You will have two vars: $allRecords, and $count.

1 Like

I know how to avoid it, I’m asking why this happens? Bug?