CActiveDataProvider

Hi.

I have on table on my database with the column ‘allowedUsers’. This field is TEXT type and filed with the usernames separated with commas.

What I need is to create a CActiveDataProvider to run CListView for users if the user is allowed on above field.

How can I achieve this?

I know its more php/mysql problem than with yii but someone can show me the way?




		$criteriaPrivate=new CDbCriteria;

		$criteriaPrivate->addcondition('status=1');

		$criteriaPrivate->addincondition('allowedUsers',array(Yii::app()->user->username));

		$dataProviderPrivate=new CActiveDataProvider('Gallery', array(

			'criteria'=>$criteriaPrivate,

			'pagination'=>array(

				'pageSize'=>Yii::app()->user->getState('pageSize', 50),

				),

			'sort'=>array(

				'defaultOrder'=>'weight ASC',

				),

			)		

		);




Did you try this?




$criteriaPrivate->addCondition('allowedUsers LIKE :user',array(':user'=>'%'.Yii::app()->user->username).',%'));



Oh dude. Thanks… I got it!