Display Crud Entries Just By User

I’m trying to display the CRUD Documents by the current user. I’ve been looking at CDbCriteria and tried adding it to actionIndex():


    public function actionIndex()

    {

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


        $criteria=new CDbCriteria;

        $criteria->compare('user_id',$user_id,true);

        

        $dataProvider=new CActiveDataProvider('Document');

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

            'dataProvider'=>$dataProvider,

            'criteria' => $criteria,

        ));

    }

…however it continues to show all the Documents rather than just the ones by the current user. I’m not sure what I’m doing wrong.

Basically all I want to do is SELECT * FROM document WHERE user_id=$user_id


Edit: Fixed. Removed the $criteria’s and defined the criteria in CActiveDataProvider.