如何在 yii find() 中输入条件?

How to input condition in yii find()?

我有两个 tables AccountUser.

Account table 包含 account_idusernamepassword

User table 包含 user_idaccount_idfirst_namelast_name.

我想要的是 yii 显示登录的 user table 的内容,所以我使用了这段代码

$user= Yii::app()->user->id; //to get the account_id of user logged in
$userModel = User::model()->find(array('condition'=>'account_id' == $user));
//to find data in the user table with the account_id similar to the
//account_id of the one logged in
print_r($userModel); //to check if I got the correct data

但出于某种原因,无论谁登录,print_r($userModel) 都会返回带有 account_id == 1

的数据

请帮忙:/

如果您使用的是 Yii 1,您可以尝试使用 findByAttribute

$userModel = User::model()->findByAttributes(array('account_id'=>$user));