Yii关系,数组检查以查看值是否存在

I am trying to create a if then statement to only display something if a value in a array exists.

Given two tables Address and Player I have the following relation

'displayAddress' => array(self::HAS_MANY, 'Address', 'PlayerId', 
                        'condition'=>array('IsHome=:home', 'IsWork=:wok'),
                        'params' => array(':hom'=>'Y', ':wok'=>'N')),

Now in a Player view I want to check to see if that player has any addresses where it is only their home and not their work.

I have tried setting a function for the array and checking doing isset in the view as well as in_array() and array_key_exists() but I haven't been able to solve it.

The relation you have should / will return only instances where IsHome=Y and IsWork=N. Does this work as expected? If not, try:

'displayAddress' => array(self::HAS_MANY, 'Address', 'PlayerId', 'condition'=>'IsHome=:home AND IsWork=:wok', 'params' => array(':hom'=>'Y', ':wok'=>'N')),