How can I perform a DATEDIFF
function in CDbCriteria
relations in yii
$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))'
)
);
I tried using the above code, Then got an error saying DATEDIFF
not found in particular table. So I add subscription relation as follows
'return array(
'company'=>array(self::BELONGS_TO,'Users',array('user_id'=>'user_id')),
'subscription'=>array(self::STAT,'SubscriptionDetails','subscription_startdate'),
);
Now also showing the below error
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found:
1054 Unknown column 'Array' in 'field list'
Is this the right way to perform date difference in yii relations? Thanks in Advance