php - How to input condition in yii find()? -
i have 2 tables account , user.
account table contains account_id, username, password
while user table contains user_id, account_id, first_name, last_name.
what want yii display contents of user table of 1 logged in used code
$user= yii::app()->user->id; //to account_id of user logged in $usermodel = user::model()->find(array('condition'=>'account_id' == $user)); //to find data in user table account_id similar //account_id of 1 logged in print_r($usermodel); //to check if got correct data but reason, no matter logs in, print_r($usermodel) returning data account_id == 1
please :/
if using yii 1 can try findbyattribute
$usermodel = user::model()->findbyattributes(array('account_id'=>$user));
Comments
Post a Comment