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


PHP MyDB::getPDO方法代碼示例

本文整理匯總了PHP中MyDB::getPDO方法的典型用法代碼示例。如果您正苦於以下問題:PHP MyDB::getPDO方法的具體用法?PHP MyDB::getPDO怎麽用?PHP MyDB::getPDO使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MyDB的用法示例。


在下文中一共展示了MyDB::getPDO方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: performUpgrade

 /**
  * Force the password hash to be recalculated and store the new hash in
  * the database. Return true if the upgrade succeeded.
  */
 private function performUpgrade()
 {
     /* Note, that the upgrade CAN be performed even when we don't know the
      * original password. However, the process in slightly different in
      * such case. */
     if ($this->correctPassword === null) {
         /* We don't know the password. */
         $previousRounds = $this->rounds;
         if ($previousRounds > $this->wantedHashingRounds) {
             /* We would have to reduce the number of rounds, which is
              * impossible in this case. No update can be performed. */
             return false;
         }
         $this->rounds = $this->wantedHashingRounds;
         if ($previousRounds <= 1) {
             /* Since the first round doesn't use a salt, it is safe for us
              * to change it. */
             $this->salt = self::generateRandomString($this->wantedSaltLength);
         }
         $this->hash = $this->computeHash($this->hash, $previousRounds);
     } else {
         /* The correct password is known. In that case, we will generate
          * the hash "from scratch", and with a new salt. */
         $this->rounds = $this->wantedHashingRounds;
         $this->salt = self::generateRandomString($this->wantedSaltLength);
         $this->hash = $this->computeHash($this->correctPassword);
     }
     $db = MyDB::getPDO();
     $c = $db->prepare("\n            update `user`\n            set\n                password = :password,\n                password_salt = :password_salt,\n                password_hashing_rounds = :password_hashing_rounds\n            where\n                user_id = :user_id\n        ");
     $c->bindParam(":user_id", $this->user_id);
     $c->bindParam(":password", $this->hash);
     $c->bindParam(":password_salt", $this->salt);
     $c->bindParam(":password_hashing_rounds", $this->rounds);
     $c->execute();
     return true;
 }
開發者ID:pawelzielak,項目名稱:opencaching-pl,代碼行數:40,代碼來源:passwordManager.php


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