Hello,
I'm completely new to Yii and PHP. I have setup Yii and created a new project called MyFirstYii. I'm following the blog demo application to learn the Yii framework.
Now I'm working on the UserIdenty.php file. I want to extend the blog example with an additional field in the User table called lastLogin DATETIME.
And now I'm stuck. The example uses for all datetime fields in the database an integer. I do understand why this is done, it's easy and portable across all databases. But if you want to use external tools on the database, an integer won't be converted to a datetime.
Could someone please give me a coding example how to update the lastLogin field, as a DATETIME field, database independend ? And how should the reverse be coded, retrieving a DATETIME field and converting is to a PHP time ?
The code I have so far is:
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$username=strtolower($this->username);
$user=User::model()->find('LOWER(username)=?',array($username));
if($user===null)
{
$this->errorCode=self::ERROR_USERNAME_INVALID;
return false;
}
if($this->password!==$user->password)
{
$this->errorCode=self::ERROR_PASSWORD_INVALID;
return false;
}
$this->_id=$user->id;
$this->username=$user->username;
$this->errorCode=self::ERROR_NONE;
//Update lastLogin
//$currenttime = date( 'Y-m-d H:i:s', time());
return true;
}
Thanks in advance,
Mirco