如何在yii
中的DATEDIFF
关系中执行CDbCriteria
函数
$criteria->with = array(
'company'=>array(
'condition'=>"user_type=2 AND approval_status='A'",
'select'=>'user_company'
),
'subscription'=>array(
'condition'=>"subscription_status='A'",
'select'=>'DATEDIFF(DATE(NOW()),DATE(subscription_startdate))'
)
);
我尝试使用上面的代码,然后收到错误,说明在特定表中找不到DATEDIFF
。
所以我添加订阅关系如下
'return array(
'company'=>array(self::BELONGS_TO,'Users',array('user_id'=>'user_id')),
'subscription'=>array(self::STAT,'SubscriptionDetails','subscription_startdate'),
);
现在还显示以下错误
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found:
1054 Unknown column 'Array' in 'field list'
这是在yii关系中执行日期差异的正确方法吗? 在此先感谢