Vorrei creare una tabella con dei dati presi da una query sql
Nel controller ho:
$sql="...(qui c'è la lunga query sql)";
$command=Yii::app()->db->createCommand($sql); // execute a query SQL
$dipendenti = $command->queryAll();
Nella view in questo momento riesco a prendere il risultato in questo modo:
foreach ($dipendenti as $dipendente){
echo $dipendente["COGNOME"];
}
Vorrei crearmi una gridview con yii che mi mostri i dati, ho provato cosi ma manca qualcosa:
nel controller:
$dataProvider=new CArrayDataProvider($dipendenti, array(
'id'=>'arcdipan',
'sort'=>array(
'attributes'=>array(
'nome', 'cognome'
),
),
'pagination'=>array(
'pageSize'=>10,
),
));
nella view:
$this->widget('bootstrap.widgets.TbJsonGridView', array(
'dataProvider' => $dataProvider,
'type' => 'striped bordered condensed',
'summaryText' => false,
'cacheTTL' => 10, // cache will be stored 10 seconds (see cacheTTLType)
'cacheTTLType' => 's', // type can be of seconds, minutes or hours
'columns' => array(
'nome',
'cognome',
array(
'header' => Yii::t('ses', 'Edit'),
'class' => 'bootstrap.widgets.TbJsonButtonColumn',
'template' => '{view} {delete}',
),
),
));