如何使用3个模型在cgridview中完成以下查询结果。?
select a.id,
a.name,
b.group_id,
c.id,
c.client_id,
c.title
from users_phone_numbers a,
phone_number_group_assignment b,
client_groups c
where a.id = b.phone_number_id
and b.group_id=c.id;
plz回复谢谢
答案 0 :(得分:0)
$rawData=Yii::app()->db->createCommand('... query ...')->queryAll();
$dataProvider=new CArrayDataProvider($rawData, array(
'id'=>'a.id',
'sort'=>array(
'attributes'=>array(
'a.name, b.group_id, ...',
),
),
));
将$dataProvider
作为DataProvider传递到网格视图。