Hello!
I receive a following error, when try to render a CActiveDataProvider instance:
CDbCommand failed to execute the SQL statement: SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "personLds"
LINE 1: …gender" AS "t0_c1" FROM "ps_t_person" "t" WHERE ("personLds…
^. The SQL statement executed was: [sql]SELECT "t"."id" AS "t0_c0", "t"."gender" AS "t0_c1" FROM "ps_t_person" "t" WHERE ("personLds".language_id=1) LIMIT 10[/sql]
Here is the code:
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Person',
array(
'criteria'=>array(
'with'=>array('personLds'),
'condition'=>'"personLds".language_id=1',
),
)
);
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
Database schema:
1st table: "person"
Column list:
id
gender
2nd table: "person_ld"
Column list:
id
firstname
lastname
…
language_id
Foreign Key:
[sql]ALTER TABLE ps_t_person_ld
ADD CONSTRAINT fk_person_ld_person FOREIGN KEY (person_id)
REFERENCES ps_t_person (id) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT;[/sql]
Can anybody explain please, why the sql statement in the error above dosn’t contain […JOIN person_ld…] part? Why “with” option specified in the call to CActiveDataProvider constructor is ignored?