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?


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



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





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

$criteria = new CDbCriteria();

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

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

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


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

Another alternative:

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

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