SQL query help in Yii framework(count, group by)!

I was wondering if anyone can help me with writing this query with CDbCriteria.

SELECT COUNT(*), vrste_odsustva_id FROM doob.calendar WHERE radnik_id=19 group by vrste_odsustva_id;

I tryed with this but he didn’t list me anything

$criteria= new CDbCriteria;
    $criteria->select = '*, COUNT(*)';  // is also the default value so you can leave this line out
    $criteria->condition = 'vrste_odsustva_id != NULL';
    $criteria->params = array(':radnik_id' => $radnik_id);
    $criteria->group = 'vrste_odsustva_id';

I just get an empty array.

Note: It’s Yii 1.1.6 version


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s