I have a problem with CArrayDataProvider apparently returning empty value. When I type the SQL (see below), on mysql, I get 7 records, my view displays 7 lines but with empty values.

Here is the necessary code, if you need more, please ask me.

actionIndex of the Post Controller

        $user_id = Yii::app()->user->id;
        $sql = 'SELECT * FROM post 
                LEFT JOIN comment ON = comment.post_id
                AND comment.user_id =:user_id
                LIMIT 0 , 30 ';
        $command->bindParam(':user_id', $user_id,PDO::PARAM_STR);

        $rawData = $command->queryAll();

        $dataProvider=new CArrayDataProvider($rawData, array(
                    'defaultOrder' => 'post.created',


view Index

<?php $this->widget('zii.widgets.CListView', array(
)); ?>

and view _view

<?php echo CHtml::encode(Post::model()->subject); ?>

Is anyone can see where the problem comes from?

Thank you in advance for your help.

Was it helpful?


Use this in your _view.php instead of whatever you are doing:

<?= CHtml::encode($data['subject']); ?>

If it still fails, check to see if the $dataProvider actually has records:

<?php var_dump($dataProvider->data); ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow