当前位置: 首页>>代码示例>>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;未经允许,请勿转载。