How can I do a basic model()->find??

Hi there,

I’ve seen many tutorial sites that expalin how to use model()->find with one parameter as a value. but what about two?

Ie:

I want to find all users with first name Paul, and last name Smith

[size=2]

[/size]

[size=2]how do I do this?[/size]

[size=2]

[/size]

[size=2]

[/size]

[size=2]Please help![/size]




$criteria = new CDbCriteria();

$criteria->compare('first_name', 'Paul');

$criteria->compare('last_name', 'Smith');

$users = User::model()->findAll($criteria);



Alternative:


User::model()->findAll('first_name=? AND last_name=?', array('Paul', 'Smith'));

Another alternative:




User::model()->findAllByAttributes(array('first_name'=>'Paul', 'last_name'=>'Smith'));



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

what kind of output that will shown using all of those method?

mine shows not only the data i want it to be.

it will return you set of models

added that to common questions

http://www.yiiframework.com/wiki/258/common-yii-questions/#hh9