Hello,
I have a model ‘User’ that relates to it itself via created_user_id and updated_user_id.
public function relations() {
return array(
'create_user' => array(self::BELONGS_TO, 'User', 'create_user_id'),
'created_users' => array(self::HAS_MANY, 'User', 'create_user_id'),
'update_user' => array(self::BELONGS_TO, 'User', 'update_user_id'),
);
}
In my controller I try to get the whole data to be used for a datagrid.
protected function handleReadAction() {
$pi = $this->getPagingInfo();
$total = User::model()->count();
$criteria = new CDbCriteria();
$criteria->with=array('create_user','update_user');
$criteria->offset = $pi['start'];
$criteria->limit = $pi['limit'];
$criteria->order = 't.username ASC';
$data = User::model()->findAll($criteria);
return $this->ExportToJSONDataSource($data, $total);
}
$data does not contain the related data.
Any ideas?
Thanks in advance.
Daniel Khan