Random filter in CActiveDataProvider

Hi everyone…how can i implement a filter in CActiveDataProvider, I want to display random 50 accounts from all the useraccounts except the account of currently logged in user. thanks




public function actionIndex()

	{

		$dataProvider=new CActiveDataProvider('Useraccounts',array('Pagination'=>array('pageSize'=>6,),));

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

			'dataProvider'=>$dataProvider,

		));

	}



Use an order condition.




public function actionIndex()

	{

		$dataProvider=new CActiveDataProvider('Useraccounts',

array('Pagination'=>array('pageSize'=>50,), 'criteria' => array('order' => new CDbExpression('RAND()'))));

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

			'dataProvider'=>$dataProvider,

		));

	}



You will have to tinker with this, since every new page will fetch another random result, also ORDER BY RAND() actually sucks (it’s slow).

it works thanks Luke, lets say for example I have 1000 user accounts, i just wanted to get random 50 useraccounts from 1000 to be displayed by 6 perpage