Hier ein kleines Beispiel (wenn ich Struktur/Zusammenhänge richtig verstanden habe):
//Model UserGroupDataRevision
class UserGroupDataRevision extends CActiveRecord
{
public function relations()
{
return array(
'userGroup' => array(self::BELONGS_TO, 'UserGroup', 'group_id'),
'userGroupData' => array(self::BELONGS_TO, 'UserGroupData', 'group_data_id'),
);
}
//....
}
//model UserGroup
class UserGroup extends CActiveRecord {...}
//model UserGroupData
class UserGroupData extends CActiveRecord {...}
Kriterien:
$criteria = new CDbCriteria();
$criteria->select = 'ugdr.revision_version'; // other fields
$criteria->alias = 'ugdr';
$criteria->with = array(
'userGroup' => array(
'alias' => 'ug',
'together' => true,
'select' => array('ug.user_id'), // other fields
),
'userGroupData' => array(
'alias'=> 'ugd',
'together' => true,
'select'=>array('ugd.group_id, ugd.group_name'), // other fields
),
);
$criteria->group = 'rgd.group_id';
$criteria->order = 'rgd.group_id'; // or something else
Datenprüfung:
$dataProvider = new CActiveDataProvider('UserGroupDataRevision', array(
'criteria' => $criteria,
)
);
var_dump($dataProvider->getData());
die();