は私がyiiのdataproviderでレコードを表示する方法は?
は、私は3つのテーブル
company_userを持っている...
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は事前に私 感謝を助けるdataProviderのこのクエリを使用したいです - > id、company_id、user_id、first_name、last_name
企業 - > id、name_of_company
ユーザー - > ID、ユーザ名、パスワード
私は事前にcompany_user +ユーザ名
ユーザーからの感謝のすべてのレコードが... :)
私が欲しい欲しいリストCGridViewで
私のユーザモデルでこのタイプの関係を書いた
のYiiで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
plz私の更新された質問を見る.... @Örs – User1988
こんにちは@Örs、今plzこの関係を使用する方法を言う? – User1988