本文整理汇总了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();
}