1

I have an action like this:

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
    ));
}

And then i want to show the result of query in View file update_daily.php using widget for column Duration :

   $this->widget('bootstrap.widgets.TbGridView', array(
 'columns' => array(
                    'name'=> 'Duration',
                    'value'=> $command,
                ),

)

But, the it doesn't work and error.

1 Answers1

0

You can refer this link to print and check whether your query is current or not

also use

print_R($command);die();

above the render to check for result return by query

Paritosh Mahale
  • 1,238
  • 2
  • 14
  • 42