Reputation: 319
I am new in Yii. Now i have encountered problem with active record in yii.
So , I have normal sql here :
$sqlText = "SELECT *
FROM tbl_webservicetokens
WHERE clienttoken = '{$appToken}'
AND
systimestamp < expiredate";
I want to use active record. But i endeavored
$post=TBLWEBSERVICETOKENS::model()->find(
'CLIENTTOKEN=:appToken AND EXPIREDATE>:systimestamp',
array(
':appToken'=>$appToken,
':systimestamp'=>'systimestamp'));
But i had error! any idea?
Upvotes: 0
Views: 724
Reputation: 2506
You are passing wrong data type (string) for the date time field have you noted that
$post=TBLWEBSERVICETOKENS::model()->find(
'CLIENTTOKEN=:appToken AND EXPIREDATE>:systimestamp',
array(
':appToken'=>$appToken,
':systimestamp'=>$systimestamp)); //$systimestamp where your time data type value resides
If you still have the error Read Me!!!
Upvotes: 1
Reputation: 319
Well, It seems to me i find answer:
$criteria = new CDbCriteria;
$criteria->condition = "ID = 1212 AND CLIENTTOKEN = 'ws546b041c85ad38a2c1f4224e1e39fe09cf76a3c8703c5'"; $models = TBLWEBSERVICETOKENS::model()->findAll($criteria);
Upvotes: 0
Reputation: 1135
Try this query. I think this will work for you.
$post= TBLWEBSERVICETOKENS::model()->find(array(
'select'=>'*',
'condition'=>'CLIENTTOKEN=:appToken AND EXPIREDATE>:systimestamp',
'params'=>array(':appToken'=>$appToken,':systimestamp'=>'systimestamp'))
);
Upvotes: 1