[Solved] how to check, if authenticated user in array from db


Use LIKE query for checking your user id exist or not in users column.

$user = Yii::app()->user->id;
$result = Yii::app()->db->createCommand('SELECT * FROM project WHERE users  LIKE "%'.$user.'%"')->queryAll();
if(count($result)){
    //Your other scripts to show in grid view
}

If you have a Project model class then you also can use:

$user = Yii::app()->user->id;
$criteria = new CDbCriteria;
$criteria->select="*";
$criteria->compare('t.users', $user, true);
$results = Project::model()->findAll($criteria);

1

solved how to check, if authenticated user in array from db