title: Yii: How to get records from a CDataProvider , and how to echo record fields?
body: <p>I've a custom data provider in my Model</p>
  
  <p>I tryied this in controller</p>
  
  <pre><code>public function actionMonthTotal()
  {
      $model=new Rapporti();
      $this-&gt;render('monthTotal',array(
              'dataProvider'=&gt;$model-&gt;monthTotal(),
      ));
  }
  </code></pre>
  
  <p>Where monthTotal is the model function that give me a DataProvider</p>
  
  <p>Actually 'monthTotal' is a copy/past of view.php and it uses a clistView using _monthTotal, that is a copy/past of  _view.php</p>
  
  <p>I Need to simply get the dataset from dataProvider (a 'SELECT COUNT, SUM, SUM, etc...") and iterate into recordset to echo a simple TABLE into monthTotal view . So ... </p>
  
  <p><strong>how to use a dataProvider from a view to get records and how to iterate trough recors?</strong></p>
  
  <p>My month total is this and is in 'Report' Model</p>
  
  <p>Actually report is in a relation Report N -> 1 Pionierato (sorry for italian terms, but are only object names)</p>
  
  <pre><code>public function totalMonth() {
      $criteria = new CDbCriteria();
      $criteria-&gt;with = array ('pionierato');
      $criteria-&gt;condition = 'dataBetel=:month';
      $criteria-&gt;select = "COUNT(t.id) as numProclamatori,
                              pionierato.tipo as tipoPionierato,
                              SUM(libri) as sommaLibri,
                              SUM(opuscoli) as sommaOpuscoli,
                              SUM(ore) as sommaOre,
                              SUM(riviste) as sommaRiviste,
                              SUM(visite) as sommaVisite,
                              SUM(studi) as sommaStudi";
  
      $criteria-&gt;group  = "t.dataBetel, t.pionieratoId";
      $criteria-&gt;params = array ('month' =&gt; "2012-09-01");
  
      $dataProvider=new CActiveDataProvider('Rapporti', 
                                             array ('criteria' =&gt; $criteria)
                                           );
  
      return $dataProvider;
  }
  </code></pre>
  
  <p>I need to use this dataprovider to get the 3 record it will output and print a 3-row table. Static.</p>
  
  <p>Using suggestion from first answer, i got this:</p>
  
  <p><img src="https://i.stack.imgur.com/EBN9i.png" alt="Actual results"></p>