title: Invalid argument supplied for foreach()
body: <p>I'm working in  Yii framework.  In my index action I created the dataprovider in the following way</p>
  
  <pre><code>$connection=Yii::app()-&gt;db;
  $user_id = Yii::app()-&gt;user-&gt;id;
  $sql = 'SELECT * FROM post
          LEFT JOIN comment ON post.id = comment.post_id
          AND comment.user_id =:user_id
          LIMIT 0 , 30 ';
  $command=$connection-&gt;createCommand($sql);
  $command-&gt;bindParam(':user_id', $user_id,PDO::PARAM_STR);
  
  $rawData = $command-&gt;execute();
  
  $dataProvider=new CArrayDataProvider($rawData, array(
                      'id'=&gt;'user',
                      'sort'=&gt;array(
                      'defaultOrder' =&gt; 'post.created',
                      ),
                      'pagination'=&gt;array(
                      'pageSize'=&gt;10,
                      ),
          ));
  </code></pre>
  
  <p>then I render the index view</p>
  
  <pre><code>$this-&gt;render('index',array(
              'dataProvider'=&gt;$dataProvider,
              'category_id'=&gt;$category_id,
          ));
  </code></pre>
  
  <p>Index view is doing </p>
  
  <pre><code>&lt;?php $this-&gt;widget('zii.widgets.CListView', array(
      'dataProvider'=&gt;$dataProvider,
      'itemView'=&gt;'_view',
  )); ?&gt;
  </code></pre>
  
  <p>which cause the error   </p>
  
  <pre><code>Invalid argument supplied for foreach()
  
  C:\wamp\www\yii\framework\web\CArrayDataProvider.php(140)
  
       * @param array $directions the sorting directions (field name =&gt; whether it is descending sort)
        */
  
       136         foreach($directions as $name=&gt;$descending)
  137         {
  138             $column=array();
  139             $fields_array=preg_split('/\.+/',$name,-1,PREG_SPLIT_NO_EMPTY);
  140             foreach($this-&gt;rawData as $index=&gt;$data)
  141                 $column[$index]=$this-&gt;getSortingFieldValue($data, $fields_array);
  142             $args[]=&amp;$column;
  143             $dummy[]=&amp;$column;
  144             unset($column);
  145             $direction=$descending ? SORT_DESC : SORT_ASC;
  146             $args[]=&amp;$direction;
  147             $dummy[]=&amp;$direction;
  148             unset($direction);
  149         }
  </code></pre>
  
  <p>Can you help me?
  Thank you in advance</p>