Problem With The Findallbyattributes Function


I have this table “tbl_owner_users” which contains a pairs of user_id and owner_id (both are user_id’s) as a PRIMARY KEY that tells me which user (represented by user_id) connects to which Account (represented as owner_id).

I would like to display a list of those users who are connected to a specipic logged user. For example, if I am logged in I would like to see those users who are in my Account.

I want to use the findAllByAttributes() function but I think I don’t use it well.

This is my code:

$ownerIdTemp = Yii::app()->user->id; //gets the id of the logged user

$sql = "owner_id =".$ownerIdTemp ;

$users = OwnerUsers::model()->findAllByAttributes(‘user_id’,$sql, ‘user_id’);

What am I doing wrong?

$ownerId = Yii::app()->user->id;

$modelList = OwnerUsers::model()->findAllByAttributes(array('owner_id' => $ownerId));