phpactiverecordyiicactiverecord

How to get a particular row in CActiveRecord in Yii framework?


Lets say I have a record like the following

Users - id - username - password

While login i want to check user's x_username, x_password with this record and i should return the matched row. How to do that in CActiveRecord?

I tried the following

$user = Users::model()->find('username = :x_username AND password = :x_password');

but its not working

How to do this?


Solution

  • try this

     $user = Users::model()->find('username = :x_username AND password = 
    :x_password',array(':x_username'=>'myname',':x_password'=>'mypassword'));
    

    OR

       $user = Users::model()->find('username = :x_username AND password = 
        :x_password',array(':x_username'=>$myname,':x_password'=>$mypassword));