$users = Users::model()->find('LOWER(EMAIL)=?',array(strtolower($this->EMAIL)));
if($users === null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if(($this->PASSWORD)!==$users->PASSWORD)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_ID=$users->USER_ID;
$this->EMAIL=$users->EMAIL;
$this->setState("USER_ID", $this->_ID);
$this->setState("EMAIL", $this->EMAIL);
$this->setState("IS_VIP", 0 or 1 - > this should be a variable with the result from the comparision);
$this->errorCode=self::ERROR_NONE;
}
return !$this->errorCode;
$users->VIP_UNTIL should be a field from the database. The problem is how to compare NOW() and VIP_UNTIL. I can't use the IF/SWITCH approach as I am extracting data. Moreover, I am extracting data, so I suppose, I can't use the CDbExpression. Actually, the task is to understand whether VIP_UNTIL > NOW() and set the VIP state property to 1. Otherwise, to assign 0 to it.
You can still use AR. You can pass a CDbCriteria instance to find(). You need to specify the 'select' property of CDbCriteria so that you can extract the needed VIP attribute using your expression.
Qiang, I understood that this might not be a solution. The problem is not in your idea, but in the fact that if I record the thing in a session, the user can stay "forever" and thus, he remains VIP until he gets logged out. The possible implementation is to perform VIP checks on sensitive places, it couldn't be dine by a custom function which checks whether the current user is VIP or not. This is actually for rules, I would be happy if this is implemented in accessControl too(I mean custom function or something)…