本文整理汇总了PHP中Model\User::getUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getUsername方法的具体用法?PHP User::getUsername怎么用?PHP User::getUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model\User
的用法示例。
在下文中一共展示了User::getUsername方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save(\model\User $user)
{
if ($this->doExists($user->getUsername())) {
throw new \Exception();
}
$stmt = $this->database->prepare("INSERT INTO `lab4` (`username` , `password`) VALUES (?, ?)");
if ($stmt === FALSE) {
throw new \Exception($this->database->error);
}
$username = $user->getUsername();
$password = $user->getPassword();
$stmt->bind_param('ss', $username, $password);
$stmt->execute();
}
示例2: doUserExist
public function doUserExist(User $user)
{
$this->database->prepare('SELECT * FROM users WHERE username = :username');
$this->database->bindValue(':username', $user->getUsername());
$this->database->fetchAll();
if ($this->database->rowCount() > 0) {
throw new exception\UserAlreadyExistException();
}
}
示例3: addUser
/**
* @return bool
* Encrypts password with the php 5.5 hashing API (uses BCrypt)
*/
public function addUser(\model\User $user)
{
$successfulRegistration = false;
$users = $this->getAllUsers();
if ($users->isInList($user->getUsername())) {
throw new \UserAlreadyExistException("User exists, pick another username.");
}
try {
$db = $this->db->getConnection();
$sql = "INSERT INTO {$this->dbTable} (" . self::$usernameColumn . ", " . self::$passwordColumn . ") VALUES (?, ?)";
$params = array($user->getUsername(), password_hash($user->getPassword(), PASSWORD_DEFAULT));
$query = $db->prepare($sql);
$query->execute($params);
$successfulRegistration = true;
} catch (\PDOException $e) {
die("Database error, please try again later");
}
return $successfulRegistration;
}
示例4: removeFollowee
/**
* Used when the person who is currently logged in wants to stop following another user
* @param User $user, person who is already following
* @param $followee, a person who is being followed
* @return bool
*/
public function removeFollowee(\model\User $user, $followee)
{
$follower = $user->getUsername();
try {
DB::getInstance()->deleteFollowee($follower, $followee);
return true;
} catch (\Exception $e) {
return false;
}
}
示例5: addNewStatus
public function addNewStatus(\model\User $user, $content)
{
if (strlen($content) > 255) {
return false;
}
try {
$username = $user->getUsername();
DB::getInstance()->addStatusToDB($username, $content);
return true;
} catch (\Exception $e) {
return false;
}
}
示例6: doLogin
/**
* Login user
*
* @param \model\User $credential
* @return bool
*/
public function doLogin(\model\User $credential)
{
$username = $credential->getUsername();
$password = $credential->getPassword();
$records = new \Db();
$records->query('SELECT username, password FROM users WHERE BINARY username = :username');
$records->bind(':username', $username);
$results = $records->single();
if (count($results) > 0 && password_verify($password, $results['password'])) {
return $this->sessionStorage->set(SessionStorage::$auth, $username);
} else {
return false;
}
}
示例7: doExist
public function doExist(\model\User $user)
{
$sqlQuery = $this->dal->prepare("SELECT EXISTS(SELECT 1 FROM Users WHERE Username=?)");
if ($sqlQuery == false) {
throw new \Exception($this->dal->error);
}
$username = $user->getUsername();
$sqlQuery->bind_param('s', $username);
$sqlQuery->execute();
$sqlQuery->bind_result($result);
$sqlQuery->fetch();
if ($result == 1) {
return true;
}
return false;
}
示例8: response
/**
* Generate user profile
* @return String HTML-code
*/
public function response()
{
return '<h1>' . $this->user->getUsername() . '</h1>
' . $this->setInfo();
}