Есть 2 модели: ReportColumns, OrganizationTypes.
Относятся как многие к одному.
прописываю связи
//ReportColumns
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(
'organizationTypes'=>array(self::BELONGS_TO, 'OrganizationTypes', 'organizationType_id'),
);
}
И пытаюсь сделать такую выборку данных:
private function getJsonData(CActiveRecord $model, CDbCriteria $criteria = null)
{
if (is_null($model) || !$model instanceof CActiveRecord) {
Yii::app()->end();
}
$returnData = $model->findAll($criteria);
$returnDataArray = array();
foreach ($returnData as $single) {
$returnDataArray[] = $single->getAttributes();
}
return CJSON::encode($returnDataArray);
}
public function actionGetLayoutReport()
{
$layouts = $this->getJsonData(ReportColumns::model()->with('organizationTypes'));
if (is_null($layouts)) {
Yii::app()->end();
}
echo $layouts;
Yii::app()->end();
}
Однако происходит такая ошибка:
CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1. The SQL statement executed was: SELECT `t`.`id` AS `t0_c0`, `t`.`label` AS `t0_c1`, `t`.`organizationType_id` AS `t0_c2`, `organizationTypes`.`id` AS `t1_c0`, `organizationTypes`.`type` AS `t1_c1` FROM `crm_report_columns` `t` LEFT OUTER JOIN `crm_organization_types` `organizationTypes` ON (`t`.`organizationType_id`=`organizationTypes`.`id`) WHERE ()
Подскажите пожалуйста что не так