SELECT and COUNT(*)

As I was not able to find the solution on the forum/documentation, I am making the question as follows.

Suppose that we have been recording the properties of the bugs such as found date etc.




$criteria = new CDbCriteria(

            	array(

                  	'condition'=>'result like \'%bug%\'',

                  	'group'=>'date',

                  	'select'=>'count(*)',

                 )

        	);


$models=Incident::model()->findAll($criteria);



I was not able to find the count in the models. How do I get it?

do like that:




$criteria = new CDbCriteria(

                array(

                        'condition'=>'result like \'%bug%\'',

                        'group'=>'date',

                        'select'=>'count(*) as bugs',

                 )

                );


$models=Incident::model()->findAll($criteria);



You have also to add the property bugs to Incident




class Incident extends CActiveRecord

{

    public $bugs;




Thank you zaccaria, it solved my issue!&nbsp; <img class=“bbc_emoticon” alt=":D" src=“http://www.yiiframework.com/forum/public/style_emoticons/default/biggrin.gif”><br>