1

我需要编辑我的 CGridView 的查询

所以在我的模型中,我将函数 search() 更改如下:

$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,
));

但从我看来,我收到一个错误,表明选择不正确:

The SQL statement executed was: SELECT COUNT(*) FROM `links` `t` join groups on links.id_group = groups.id_group WHERE links.id_user = '1'

为什么这样?

4

1 回答 1

2

除非明确设置,否则默认表别名是。t您可以通过以下方式做到这一点:

$criteria->alias = 'links';
于 2014-12-19T12:25:31.197 回答