Loadmodel Using Other Parameter

Hi there,

I’m trying to return a model to a view but I want to record sorted by a column name that is not id.

So instead of $model=Property::model()->findByPk($id);

I want to find by ‘columnName’.

Is this possible?

Thanks in advance.

http://www.yiiframework.com/doc/api/1.1/CActiveRecord#findByPk-detail

Hi

There are many ways to do that depending of what exactly you want to do

One of them:


Property::model()->findByAttributes(array('column_name'=>$your_value));