我有这样的行动:
public function actionUpdate_daily($id) {
$model = new Timesheet('searchbyvoyage');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['Timesheet']))
$model->attributes = $_GET['Timesheet'];
$modelvoyage = $this->loadModelvoyage($id);
//$vo = $this->loadVo($id, $id_voyage_order);
$command = Yii::app()->db->createCommand(
"SELECT a.id_timesheet, a.id_voyage_order, COALESCE(b.duration,0) duration FROM timesheet a LEFT JOIN
( SELECT x.*
, MAX(y.id_timesheet) previous
FROM timesheet X
JOIN timesheet Y
ON y.id_voyage_order = x.id_voyage_order
AND y.id_timesheet < x.id_timesheet
GROUP
BY x.id_timesheet
) b
ON b.previous = a.id_timesheet
WHERE a.id_voyage_order =".$id)
->queryAll(); /// var_dump($command); // die();
// Yii::app()->params['MyVar'] = $command;
$this->render('update_daily', array(
'model' => $model,
'modelvoyage' => $modelvoyage,
'command' => $command
));
}
然后我想在View文件update_daily.php中使用widget持久显示查询结果:
$this->widget('bootstrap.widgets.TbGridView', array(
'columns' => array(
'name'=> 'Duration',
'value'=> $command,
),
)
但是,它没有工作和错误。