Yii フレームワークを使用しています。複数のテーブルからレコードを取得する方法を知りたいのですが、調査しましたが、有用なリンクが見つかりませんでした。このために次のコードを使用しています。不足している場所を教えてください。
私のモデルTask.php
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(
'prj_user' => array(self::BELONGS_TO, 'User', 'id'),
);
}
モデル User.php
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(
array('task', self::HAS_MANY, 'Task','project_id')
);
}
これが私のメインコントローラーです
$criteria = new CDbCriteria;
$criteria->compare('t.id', 1);
$criteria->with = array( 'prj_user' => array('select' => 'username,title,roles', 'joinType'=>'inner join'));
$rows = Task::model()->findAll( $criteria );
それでもタスクテーブルからのみ列を取得していますが、ユーザーテーブルからさらに3つの列が必要です助けてください