I’ve just started using Yii this week and I’m trying to display the last time a user logged in by displaying the last successful entry in my login log.
public function lastLoginTime($id){
$sql = "SELECT MAX(Date_Created) FROM Login_Log WHERE Contact_ID=:contact AND Is_Successful=1;";
$parameters = array(":contact"=>$id);
$lastLoginTime=Yii::app()->db->createCommand($sql)->execute($parameters);
return $lastLoginTime;
}
Once logged in, I want to display the last successful login on the homepage:
You last logged in on <?php echo Yii::app()->user->lastLoginTime; ?>
But all that appears is a boolean, I assume, since it only shows up with -1 .