1
我想在數據提供程序如何在yii的dataprovider中顯示記錄?
select user.username ,company_user.* from user left join company_user on company_user.user_id=user.id where company_user.company_id=".$id
如何CActiveDataProvider
寫plz幫助事先我 謝謝使用此查詢...
我有3個表
company_user - > id,company_id,user_id,first_name,last_name
company - > id,name_of_company
用戶 - > ID,用戶名,密碼
我想從提前company_user +用戶名來自用戶
感謝所有記錄... :)
我想名單在CGridView中
在我的用戶模型中我已經寫下這種類型的關係
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'company_user' =>array(self::HAS_ONE,'CompanyUser','user_id','select' =>array('first_name','status'),
'with'=>array('company'=>array(self::BELONGS_TO, 'Company', 'company_id','joinType' => 'INNER JOIN')),
),
'company_user_rel_only' =>array(self::HAS_ONE,'CompanyUser','user_id','select' =>array('first_name', 'last_name')),
}
如果使用Gii創建模型,則應該已建立關係。嘗試使用它們。 – adamors 2012-04-16 09:11:37
plz查看我更新的問題.... @Örs – User1988 2012-04-16 09:13:41
hello @Örs,現在請說說如何使用這種關係? – User1988 2012-04-16 09:21:40