Hello friends
I some cases I need return only a count, so to do it I use something like:
$count = MyModel::find()->where(['field'=>'string'])->count();
Works very well, but I need to put a limit like:
$count = MyModel::find()->where(['field'=>'string'])->limit(20)->count();
Dont works, give result but if exist more than 20 lines, the result bring count of all lines
So I do it:
$count = MyModel::find()->where(['field'=>'string'])->limit(20)->all();
$x = count($count);
But it bring me a array of data and I want only de count value.
There is a way to use ‘…->limit(20)->count()’ ?;