I have a database table that is to store a certain token with expirytime.
I have this function in the model to get the data based on the token under the limited expirytime.
However, for some reason whenever I use ‘addCondition’ it gives empty result.
Here is the code that I use:
$crit = new CDbCriteria(); $crit->addCondition("token='$token'"); $crit->addCondition("expirytime > ".strtotime('now')); $crit->addCondition("status=1"); $crit->order = "expirytime DESC"; $models=$this->findAll($crit); return $models;
I have made sure that the input ($token) is correct.
The column name is correct.
I also make another test without the expirytime limitation as the following (and it returns data)
$model=$this->findByAttributes(array('token'=>$token)); return $model;
Is there something that I miss?