I am appreciated if someone shows a complete example on how to use findByAttributes in Yii framework.
Official doc @ http://www.yiiframework.com/doc/api/1.1/CActiveRecord#findByAttributes-detail
public CActiveRecord findByAttributes(array $attributes, mixed $condition='', array $params=array ( ))
I know how to use $attributes. I do not see a good reason to use $condition and $params in findByAttributes.
Please tell me under what scenario, you use them in findByAttributes.
Thank you
It seems like it was included to match similar function in other frameworks and best used when your query is mostly an array of column names like
array('dept_id'=>2,'active'=>'y')— there might be times in your program where it’s easier to pass an array in this format rather than having to re-write them into conditions. You might want to add additional conditions in the $condition paramater or ones that $attributes may not support likeproject_name LIKE "foo%".$params are used here like other query types, to bind condition values to column types for filtering.
see: http://www.yiiframework.com/doc/guide/1.1/en/database.ar#reading-record