本文整理匯總了PHP中Model\User::GetUserName方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::GetUserName方法的具體用法?PHP User::GetUserName怎麽用?PHP User::GetUserName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model\User
的用法示例。
在下文中一共展示了User::GetUserName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: SaveLoginOnClient
public function SaveLoginOnClient(\model\User $user)
{
// Prepare values
$cookieValues = implode(':', array($user->GetUserName(), $user->GetToken(), $user->GetSignature()));
// Save values in cookie (expires in 30 days)
return setcookie(self::$COOKIE_ID, $cookieValues, time() + 60 * 60 * 24 * self::$COOKIE_VALID_DAYS);
}
示例2: Add
public function Add(\model\User $user)
{
if ($this->GetRegistrationsForHour() > self::$MAX_REGISTRATIONS_PER_HOUR) {
throw new \Exception("Max number of registrations per hour reached. Please try again in 30-60 minutes.");
}
// Throw exception if username is taken
if ($this->GetUserByUsername($user->GetUserName())) {
throw new \Exception(self::$DB_USERNAME_EXISTS);
}
try {
// Prepare db statement
$statement = self::$db->prepare('INSERT INTO ' . self::$DB_TABLE_NAME . ' (user_id, user_name, user_firstname, user_surname, user_password, created)' . ' VALUES ' . '(NULL, :userName, :firstName, :surName, :password, NOW())');
// Prepare input array
$inputArray = ['userName' => $user->GetUserName(), 'firstName' => $user->GetFirstName(), 'surName' => $user->GetSurName(), 'password' => $user->GetPassword()];
// Execute db statement
$statement->execute($inputArray);
// Check if db insertion was successful
return $statement->rowCount() == 1;
} catch (\Exception $exception) {
throw new \Exception(self::$DB_INSERT_ERROR);
}
}
示例3: GetUserLoginsForHour
public function GetUserLoginsForHour(\model\User $user)
{
try {
$returnArray = [];
// Prepare db statement
$statement = self::$db->prepare('SELECT * FROM ' . self::$DB_TABLE_NAME . ' WHERE `user_name` = :userName AND ' . ' `created` LIKE \'' . date("Y-m-d H") . '%\'');
// Prepare input array
$inputArray = ['userName' => $user->GetUserName()];
// Execute db statement
$statement->execute($inputArray);
// Fetch rows
$userRowsArray = $statement->fetchAll();
return sizeOf($userRowsArray);
} catch (\Exception $exception) {
throw new \Exception(self::$DB_QUERY_ERROR);
}
}
示例4: SetLoginUsername
public function SetLoginUsername(\model\User $user)
{
$_SESSION['last_login_uname'] = $user->GetUserName();
}