I need to limit the data returned in actionIndex

I am working on a roster maintenance application and I’d like to limit the viewing of data in the database to the users own data. In the actionIndex in the controller.php file I see the following code:




		$dataProvider=new CActiveDataProvider('FcarcMembers');

               

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

			'dataProvider'=>$dataProvider,

		));



Is there any way I can modify the data being select to include a condition such as select * from members where <the user id of this logged in user> = <the id field in members> ?

Or is there somewhere else better to apply that condition. I also need to over ride that condition when the user is an administrator.

Thanks,

Jim.

Yea… just look at the example on CActiveDataProvider:

http://www.yiiframework.com/doc/api/CActiveDataProvider

You can do it inline like it has there or pass a CDbCriteria to the data provider. There are other good examples in the demos folder (function "search()"):

yii-1.1.x/demos/blog/protected/models/Post.php

The code produced by gii includes these criteria as well and are also good examples.

Thanks, that looks like it’ll work.

Jim