I have 2 tables:
table 1: orders
columns: id, customername, time, amount
table 2: order_details
columns: id, order_id, product, quantity
this is my order_details model code:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'rel_orders' => array(self::BELONGS_TO,'orders','order_id'),
);
}
..........
public function show()
{
$criteria=new CDbCriteria;
$criteria->select = 'od.order_id, od.sld';
$criteria->alias = 'od';
#$criteria->limit = 10;
#$criteria->sort = $sort;
$criteria->with = array('rel_orders' => array(
'select' => 'rel_orders.time, , (now() - rel_orders.time) as elapsedtime',
'alias' => 'o',
));
$dataProvider = new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=>20,
),
));
return $dataProvider;
}
what is the correct way in getting the elapsed time? and display it on cgridview?