當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::getUsername方法代碼示例

本文整理匯總了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();
 }
開發者ID:rs222kn,項目名稱:1DV608_Login,代碼行數:14,代碼來源:UserDAL.php

示例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();
     }
 }
開發者ID:OskarKlintrotSkolarbeteWP14,項目名稱:1dv608-Project,代碼行數:9,代碼來源:RegistrationDAL.php

示例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;
 }
開發者ID:kk222hk,項目名稱:1dv608-laborations,代碼行數:23,代碼來源:UserRepository.php

示例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;
     }
 }
開發者ID:Janste,項目名稱:PHP_MVC_Simple_Social_Network,代碼行數:16,代碼來源:Followers.php

示例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;
     }
 }
開發者ID:Janste,項目名稱:PHP_MVC_Simple_Social_Network,代碼行數:13,代碼來源:StatusHandler.php

示例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;
     }
 }
開發者ID:rn222cx,項目名稱:project_1DV608,代碼行數:20,代碼來源:User.php

示例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;
 }
開發者ID:ksvenzzon,項目名稱:Registration,代碼行數:16,代碼來源:memberDAL.php

示例8: response

    /**
     * Generate user profile
     * @return String   	HTML-code
     */
    public function response()
    {
        return '<h1>' . $this->user->getUsername() . '</h1>
			' . $this->setInfo();
    }
開發者ID:ea222pu,項目名稱:1DV608-Project,代碼行數:9,代碼來源:UserProfileView.php


注:本文中的Model\User::getUsername方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。