I have a relation in one of my CActiveRecord models that requires a simple INNER JOIN.
Expressed as an SQL statement the relation would look like this:
“SELECT * FROM T1 INNER JOIN T2 ON T2.related_id = T1.id WHERE T2.status = ‘1’”
With ‘T1’ being the table I want a list of records for, and my model being a CActiveRecord instance of ‘T2’.
How can I put that into a CActiveRecord relation?
$criteria->join ='INNER JOIN T2 ON T2.related_id = T.id;
$criteria->condition = " T2.status = ‘1’ ";
Thanks n-r for the reply but I wasn’t clear enough in my initial post. What I need is to do this in the “relations()” function in my model class that extends CActiveRecord i.e.
public function relations()
'author'=>array(self::BELONGS_TO, 'User', 'author_id'),