久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <tfoot id='4V7Tm'></tfoot>
        <bdo id='4V7Tm'></bdo><ul id='4V7Tm'></ul>
    1. <small id='4V7Tm'></small><noframes id='4V7Tm'>

        <legend id='4V7Tm'><style id='4V7Tm'><dir id='4V7Tm'><q id='4V7Tm'></q></dir></style></legend>

      1. <i id='4V7Tm'><tr id='4V7Tm'><dt id='4V7Tm'><q id='4V7Tm'><span id='4V7Tm'><b id='4V7Tm'><form id='4V7Tm'><ins id='4V7Tm'></ins><ul id='4V7Tm'></ul><sub id='4V7Tm'></sub></form><legend id='4V7Tm'></legend><bdo id='4V7Tm'><pre id='4V7Tm'><center id='4V7Tm'></center></pre></bdo></b><th id='4V7Tm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4V7Tm'><tfoot id='4V7Tm'></tfoot><dl id='4V7Tm'><fieldset id='4V7Tm'></fieldset></dl></div>

        未捕獲的異常 'PDOException' 帶有消息 'S

        Uncaught exception #39;PDOException#39; with message #39;SQLSTATE[HY093]: Invalid parameter number#39;(未捕獲的異常 PDOException 帶有消息 SQLSTATE[HY093]: Invalid parameter number)
        <tfoot id='ugQvu'></tfoot>
        <i id='ugQvu'><tr id='ugQvu'><dt id='ugQvu'><q id='ugQvu'><span id='ugQvu'><b id='ugQvu'><form id='ugQvu'><ins id='ugQvu'></ins><ul id='ugQvu'></ul><sub id='ugQvu'></sub></form><legend id='ugQvu'></legend><bdo id='ugQvu'><pre id='ugQvu'><center id='ugQvu'></center></pre></bdo></b><th id='ugQvu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ugQvu'><tfoot id='ugQvu'></tfoot><dl id='ugQvu'><fieldset id='ugQvu'></fieldset></dl></div>
          <tbody id='ugQvu'></tbody>
          • <bdo id='ugQvu'></bdo><ul id='ugQvu'></ul>

              <small id='ugQvu'></small><noframes id='ugQvu'>

              <legend id='ugQvu'><style id='ugQvu'><dir id='ugQvu'><q id='ugQvu'></q></dir></style></legend>

                • 本文介紹了未捕獲的異常 'PDOException' 帶有消息 'SQLSTATE[HY093]: Invalid parameter number'的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  每當我嘗試使用 PDO 插入我的數據庫時,我都會收到錯誤消息.

                  I'm receiving an error whenever I attempt to insert into my database using PDO.

                  public function save($primaryKey = "") {
                          $validate = $this->rules();
                          if ($validate === true) {
                              $properties = '';
                              $values = '';
                              $bindings = array();
                              $update = '';
                              foreach ($this as $property => $value){
                                  if ($property === "conn") {
                                      continue;
                                  }
                                  $properties .= $property . ',';
                                  $values .= ':' . $property . ',';
                                  $update .= $property . ' = :' . $property . ',';
                                  $bindings[':'.$property] = $value;
                              }
                              $sql_string = 'INSERT INTO ' . get_class($this) . ' (' . rtrim($properties, ',') . ') ';
                              $sql_string .= 'VALUES (' . rtrim($values, ',') . ') ON DUPLICATE KEY UPDATE ' . rtrim($update, ',') . ';';
                              $result = $this->executeQuery(NULL, $sql_string, $bindings);
                              $this->buildObject($result);
                              if (!empty($primaryKey)) {
                                  $this->$primaryKey = $this->conn->lastInsertId();
                              }
                              return $result;
                          } else {
                              return $validate;
                          }
                      }
                  
                  public function executeQuery($object, $sql_string, $bindings = null) {
                          $stmt = $this->conn->prepare($sql_string);
                          if (!empty($bindings)) {
                              if (!$stmt->execute($bindings)) {return false;}
                          } else {
                              if (!$stmt->execute()) {return false;}
                          }
                          $result = (!empty($object) ? $stmt->fetchAll(PDO::FETCH_CLASS, $object) : $stmt->fetchAll());
                          return (($stmt->rowCount() > 0) ? $result : false);
                      }
                  

                  save 函數生成查詢字符串和綁定,兩者看起來都是正確的.

                  The save function generates both the query string and the bindings which both seem correct.

                  query = INSERT INTO am_administrator (firstName,lastName,username,password,email,isSuperUser,dateCreated,dateLastModified) VALUES (:firstName,:lastName,:username,:password,:email,:isSuperUser,:dateCreated,:dateLastModified) ON DUPLICATE KEY UPDATE firstName = :firstName,lastName = :lastName,username = :username,password = :password,email = :email,isSuperUser = :isSuperUser,dateCreated = :dateCreated,dateLastModified = :dateLastModified;
                  
                  bindings = array(8) { 
                  [":firstName"]=> string(5) "First" 
                  [":lastName"]=> string(4) "Last" 
                  [":username"]=> string(7) "cova-fl" 
                  [":password"]=> string(8) "password" 
                  [":email"]=> string(16) "test@testing.com" 
                  [":isSuperUser"]=> int(1) "1" 
                  [":dateCreated"]=> string(19) "2016-05-11 02:40:15" 
                  [":dateLastModified"]=> string(19) "2016-05-11 02:40:15" 
                  }
                  

                  每當我將查詢放入工作臺時,我都沒有問題,但是當我嘗試在代碼中運行它時,我收到致命錯誤:未捕獲的異常 'PDOException',消息為 'SQLSTATE[HY093]:無效的參數編號',這讓我感到困惑,因為綁定參數的數量與綁定鍵和數字匹配.任何人都可以在這個問題上啟發我嗎?

                  Whenever I put the query into workbench I have no problems, but when trying to run it in code I get Fatal Error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number' which confuses me since the number of bindings params matches the bindings keys and nummbers. Can anyone enlighten me on this issue?

                  推薦答案

                  我認為這可能是因為您在語句中對每個綁定進行了兩次 decared,例如:firstname 出現在 VALUES 子句以及 ON DUPLICATE KEY UPDATE 子句中.

                  I think this might be because you have decared each binding twice in the statement e.g. :firstname appears in the VALUES clause as well as the ON DUPLICATE KEY UPDATE clause.

                  您只向 $stmt->execute 傳遞了 8 個綁定,但 PDO 正在尋找 16 個.

                  You only pass 8 bindings to the $stmt->execute but PDO is looking for 16.

                  您可以嘗試在 ON DUPLICATE KEY UPDATE 子句中對它們的命名略有不同,為您提供一個查詢,例如

                  You could try naming them slightly different in the ON DUPLICATE KEY UPDATE clause giving you a query such as e.g.

                  <代碼>INSERT INTO am_administrator (firstName,lastName,username,password,email,isSuperUser,dateCreated,dateLastModified) VALUES (:firstName,:lastName,:username,:password,:email,:isSuperUser,:dateCreated,:dateLastModified) ON DUPLICATE KEY UPDATEfirstName = :update_firstName,lastName = :update_lastName,username = :update_username,password = :update_password,email = :update_email,isSuperUser = :update_isSuperUser,dateCreated = :update_dateCreated,dateLastModified = :update_dateLastModified;

                  這篇關于未捕獲的異常 'PDOException' 帶有消息 'SQLSTATE[HY093]: Invalid parameter number'的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                      <i id='Rz0qQ'><tr id='Rz0qQ'><dt id='Rz0qQ'><q id='Rz0qQ'><span id='Rz0qQ'><b id='Rz0qQ'><form id='Rz0qQ'><ins id='Rz0qQ'></ins><ul id='Rz0qQ'></ul><sub id='Rz0qQ'></sub></form><legend id='Rz0qQ'></legend><bdo id='Rz0qQ'><pre id='Rz0qQ'><center id='Rz0qQ'></center></pre></bdo></b><th id='Rz0qQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Rz0qQ'><tfoot id='Rz0qQ'></tfoot><dl id='Rz0qQ'><fieldset id='Rz0qQ'></fieldset></dl></div>
                      <tfoot id='Rz0qQ'></tfoot>

                        <bdo id='Rz0qQ'></bdo><ul id='Rz0qQ'></ul>

                        <small id='Rz0qQ'></small><noframes id='Rz0qQ'>

                        • <legend id='Rz0qQ'><style id='Rz0qQ'><dir id='Rz0qQ'><q id='Rz0qQ'></q></dir></style></legend>
                              <tbody id='Rz0qQ'></tbody>
                          1. 主站蜘蛛池模板: 本道综合精品 | 999久久久久久久久6666 | 久久国产成人 | 自拍偷拍小视频 | 亚洲欧美在线视频 | 欧美一区成人 | 欧美a区 | 美女国内精品自产拍在线播放 | 久久久国产一区二区三区四区小说 | 日本久久视频 | 久久国产精品一区二区三区 | 欧美一级免费看 | 国产精品乱码一二三区的特点 | 黄色播放 | 久久综合久色欧美综合狠狠 | 日日夜夜精品视频 | 日韩在线视频免费观看 | 欧美九九 | 国产综合在线视频 | 成人高潮片免费视频欧美 | 一区二区三区国产视频 | 福利网站在线观看 | 久久88| 亚洲狠狠爱一区二区三区 | 久热国产精品 | 亚洲国产精品99久久久久久久久 | 欧美日韩成人在线 | 在线亚洲欧美 | 欧美日韩国产一区二区三区 | 九九热精品视频 | 欧美一级二级在线观看 | 午夜免费视频观看 | 国产精品区二区三区日本 | 人妖videosex高潮另类 | 超碰97干| 精品一区二区三区入口 | 97精品超碰一区二区三区 | 国产精品视频一二三区 | 久久99精品久久久久久 | 夜夜干夜夜操 | 成人精品一区二区三区中文字幕 |