I need to edit the query of my CGridView
so in my model I'm changing the function search() as follow:
$criteria=new CDbCriteria;
$criteria->select = "links.title, links.url, groups.title as grouptitle";
$criteria->join = " join groups on links.id_group = groups.id_group";
$criteria->addCondition("links.id_user = '" . Yii::app()->user->getId() . "'");
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
But from my view I get an error which shows me that the select is incorrect:
The SQL statement executed was: SELECT COUNT(*) FROM `links` `t` join groups on links.id_group = groups.id_group WHERE links.id_user = '1'
why so?
The default table alias is t
unless set explicitly. You can do this by:
$criteria->alias = 'links';