Hello,
How can I get the number of result returned by a find (or findByAttributes) method ?
Thank you,
Best Regards,
Jack
Hello,
How can I get the number of result returned by a find (or findByAttributes) method ?
Thank you,
Best Regards,
Jack
Hi,
you can use Model::model()->count($condition).
See count() and countBySql() methods from CActiveRecord.
Thank you, so we have to call the sql statement twice ?
Yes, look at actionList generated by CRUD, there is example how count() is used to pagination.
If you are calling find() or findByAttributes(), then at most there is one record returned. If you are calling findAll(), then why don’t use count($results)?