当我添加$criteria->with=array('profile');
字段时,revent_datetime
总是返回 NULL,但没有返回权。为什么会发生标准?with
revent_datetime
with
控制器.php
public function actionIndex()
{
$dayofweek = date('w');
$criteria = new CDbCriteria;
$criteria->select=array("
CASE
WHEN weekday >= $dayofweek
THEN CONCAT( DATE_ADD(CURDATE(), INTERVAL weekday - $dayofweek DAY), ' ', event_time )
ELSE CONCAT( DATE_ADD(CURDATE(), INTERVAL 7 - $dayofweek + weekday DAY), ' ', event_time )
END as revent_datetime,
CASE
WHEN weekday >= $dayofweek AND list_time IS NOT NULL
THEN CONCAT( DATE_ADD(CURDATE(), INTERVAL weekday - $dayofweek DAY), ' ', list_time )
ELSE CONCAT( DATE_ADD(CURDATE(), INTERVAL 7 - $dayofweek + weekday DAY), ' ', list_time )
END as rlist_datetime
");
$criteria->with=array('profile'); // Thats the line w/ problem.
$dataProvider=new CActiveDataProvider('Eventsreminder', array(
'criteria' => $criteria
));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
输出:
$dataProvider->profile->name = Profile Test
$dataProvider->revent_datetime = NULL // here is the problem
$dataProvider->rlist_datetime = 2013-01-11 20:00:00