condition while making relation in YIi
yii
Solution
add the condition on your relation
public function relations() {
return array(
'user' => array(self::HAS_ONE, 'Users', 'f_id', array(
'condition' => 'user.type = :type',
'params' => array(':type'=>3)
)),
);
}
http://www.yiiframework.com/doc/guide/1.1/en/database.arr#relational-query-options
Problem
Agent: `agent_id (primary key)` User: ``` f_id (foreign key) type ``` I have created relation in this way ``` public function relations() { return array( 'user' => array(self::HAS_ONE, 'Users', 'f_id'), ); } ``` But I want to add more conditions like join only if `type=3` in User table. thanks.