Query Builder and CListView

Is it possible to use the data returned by a query, that was builed using the Query Builder funtion, in a CListView?

it would be nice to use the pagaing and stuff of the CListView…

You need a dataProvider, so you can use the CSqlDataProvider





$sql = Yii::app()->db->createCommand()

    ->select('*')

    ->from('tbl_user')

    ->text;


$count=Yii::app()->db->createCommand('SELECT COUNT(*) FROM tbl_user')->queryScalar();


$dataProvider=new CSqlDataProvider($sql, array(

    'totalItemCount'=>$count,

    'sort'=>array(

        'attributes'=>array(

             'id', 'username', 'email',

        ),

    ),

    'pagination'=>array(

        'pageSize'=>10,

    ),

));


//render the view with the CListView

$this->render('index',array('dataProvider'=>$dataProvider));