HI Friends,
I try to Join more than two tables with condition applied for the join table in the YII version [font="Verdana"][size="2"]1.0.7[/size][/font] .Please take a look at the following code.
Th relation for the table in tbl_messages_thread
'tbl_messages_users' => array(self::HAS_MANY, 'TblMessagesUsers', 'thread_id','together'=>true),
The tbl_messages having the relation
'tbl_messages_thread' => array(self::HAS_MANY, 'TblMessagesThread', 'message_id'),
$useremailid="abc@website.com";
$criteria=new CDbCriteria;
$criteria->condition="tbl_messages_users.user_id='".$useremailid."'";
$models=TblMessages::model()->with('tbl_messages_thread','tbl_messages_thread.tbl_messages_users','tbl_messages_thread.tbl_messages_files')->findAll($criteria);
return $models;
When I am executing the above query it throws the following error.
[color="#800000"][font="Verdana"]CDbCommand failed to execute the SQL statement: SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "tbl_messages_users"[/font][/color][color="#800000"][font="Verdana"]LINE 1: …es"."flag" AS "t0_c3" FROM "tbl_messages" WHERE ("tbl_messa…[/font][/color]
[font="Verdana"]I applied the double quotes to the Join too. Like below.[/font]
[font="Verdana"]
$criteria->condition='"tbl_messages_users".user_id='".$useremailid.'"';
[/font]
But its also Not working.How I need to apply the condition for the above query.