title: how display sql query results using tbgridview in yii
body: <p>I want to display this sql query using tbgridview in yii.</p>
  
  <p>this is my controller.</p>
  
  <pre><code>public function actionSVI(){
      $list = Workstation::model()-&gt;listSvi();
      $this-&gt;render('svi',array(
          'list'=&gt;$list,
      ));
  }
  </code></pre>
  
  <p>my model and sql query.</p>
  
  <pre><code>public function listSvi(){
      $svi = Yii::app()-&gt;db-&gt;createCommand()
                  -&gt;select('*')
                  -&gt;from('workstation')
                  -&gt;where('ws_company_id=:id',array(':id'=&gt;1))
                  -&gt;queryAll();
  
      return $svi;;
  }
  </code></pre>
  
  <p>I'm currently displaying my query using this code.</p>
  
  <pre><code>&lt;?php 
  foreach($list as $each){
      $company = Workstation::model()-&gt;findByPK($each['ws_id']);
      echo  "&lt;tr&gt;&lt;td&gt;" . $company-&gt;companyName ."&lt;/td&gt;&lt;td&gt;". CHtml::link(CHtml::encode($company-&gt;ws_id), array('view','id'=&gt;$company-&gt;ws_id))."&lt;/td&gt;&lt;td&gt;" .$company-&gt;branchName ."&lt;/td&gt;","&lt;td&gt;". $company-&gt;departmentName. "&lt;/tr&gt;&lt;/td&gt;";
      }               
  </code></pre>
  
  <p>?></p>
  
  <p>i just want to display it using this tbgridview. </p>
  
  <pre><code>&lt;?php $this-&gt;widget('bootstrap.widgets.TbGridView', array(
  'type'=&gt;'striped',
  'dataProvider'=&gt;$dataProvider,
  'template'=&gt;"{items}",
  'columns'=&gt;array(
              'companyName',
          'branchName',
          'departmentName',
          'ws_id',
      array(
          'class'=&gt;'bootstrap.widgets.TbButtonColumn',
          'template'=&gt;'{view}',
          'buttons'=&gt;array(
                  'view'=&gt;array('icon'=&gt;'icon-search'),
              ),
      ),
  ),
  )); ?&gt;
  &lt;?php $this-&gt;endWidget();?&gt;
  </code></pre>