condition while making relation in YIi -
agent:
agent_id (primary key)
user:
f_id (foreign key) type i have created relation in way
public function relations() { return array( 'user' => array(self::has_one, 'users', 'f_id'), ); } but want add more conditions join if type=3 in user table.
thanks.
add condition on 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
Comments
Post a Comment