About Addcondition

Hi guys,

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("expirytime > ".strtotime('now'));


		$crit->order = "expirytime DESC";


		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)


        return $model;

Is there something that I miss?

Please help



Instead of using addCondition, try using params. So your query would look like this:

$crit->params = array(

   'token' => $token, 

   'expirytime' => strtotime('now'),

   'status' => 1,


Thanks for the reply Matthew.

I am not in the position to test this code at the moment, but one of the query conditions is to check whether the

expirytime > strtotime('now')

Will this condition be filled using your code?