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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -