CDbCriteria

i want to filter index page by user regency iput thsi code in my controller




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

		$user= User::model()->findByAttributes(array('id' => $user_id));

//		var_dump($user->regency_id);

//		die();

		$user_reg=$user->regency_id;

		$criteria = new CDbCriteria();

		$criteria->condition = 'lksaData.regency_id=regency_id';

		$criteria->params = array('lksaData.regency_id'=>$user_reg);

		$criteria->with='lksaData';




		//$lksaDataHeader = LksaDataHeader::model()->findAll($criteria);


		$dataProvider= new CActiveDataProvider($this, array(

			'criteria'=>$criteria,));

		//$dataProvider=new CActiveDataProvider('LksaDataHeader');

		$this->render('index',array(

			'dataProvider'=>$dataProvider,



but i got this error

Fatal error: Call to a member function getDbCriteria() on a non-object in C:\xampp\htdocs\lksa_kemensos\framework\web\CActiveDataProvider.php on line 173

any mistakes in my code?and how to solve it :( thx before


$dataProvider= new CActiveDataProvider($this, array(

                        'criteria'=>$criteria,))

you should use a model as data provider first argument, not the controller ($this)

thanks gustavo for your help but when i change to $model i got this error Undefined variable: model how can i declare $model?

In your case the model is $user.

thx kokomo,yeah it works now :D