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

  • <small id='Dy4AW'></small><noframes id='Dy4AW'>

    • <bdo id='Dy4AW'></bdo><ul id='Dy4AW'></ul>

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

        為什么 PDO 不允許多個同名占位符?

        Why PDO doesn#39;t allow multiple placeholders with the same name?(為什么 PDO 不允許多個同名占位符?)
          <bdo id='9yt6I'></bdo><ul id='9yt6I'></ul>
        • <tfoot id='9yt6I'></tfoot>
        • <small id='9yt6I'></small><noframes id='9yt6I'>

                <legend id='9yt6I'><style id='9yt6I'><dir id='9yt6I'><q id='9yt6I'></q></dir></style></legend>
                  <tbody id='9yt6I'></tbody>
                <i id='9yt6I'><tr id='9yt6I'><dt id='9yt6I'><q id='9yt6I'><span id='9yt6I'><b id='9yt6I'><form id='9yt6I'><ins id='9yt6I'></ins><ul id='9yt6I'></ul><sub id='9yt6I'></sub></form><legend id='9yt6I'></legend><bdo id='9yt6I'><pre id='9yt6I'><center id='9yt6I'></center></pre></bdo></b><th id='9yt6I'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9yt6I'><tfoot id='9yt6I'></tfoot><dl id='9yt6I'><fieldset id='9yt6I'></fieldset></dl></div>

                  本文介紹了為什么 PDO 不允許多個同名占位符?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我使用 PHP 和帶有 PDO 的 MySQL.有時我需要準備一個語句,其中一個變量(占位符)在這個查詢中使用了多次.

                  I'm using PHP, and MySQL with PDO. Sometimes I need to prepare a statement with one variable (placeholder) used more than once in this query.

                  示例:

                  SELECT * FROM messages WHERE from_id = :user OR to_id = :user
                  

                  但是,如果我嘗試準備此語句,則會出現錯誤,因此我需要以如下方式執行此操作:

                  However if I will try to prepare this statement I will have an error so I need to do this in a way like this:

                  SELECT * FROM messages WHERE from_id = :user1 OR to_id = :user2
                  

                  要調用這個語句,我需要有一個這樣的數組:

                  To call this statement I will need to have an array like this:

                  array('user1'=>$user_id, 'user2'=>$user_id);
                  

                  這對我來說看起來很愚蠢!為什么 MySQL (PDO?) 不允許我多次使用一個占位符并強迫我使用需要更多控制的額外變量?!

                  It looks so stupid for me! Why MySQL (PDO?) don't allowing me to use one place holder more than once and forcing me to use extra variables which requires more control?!

                  如果查詢相對簡單(就像我在上面發布的那樣),這可以很容易地處理,但現在我構建了一個使用 5 (!!!) 單個變量的查詢.每次添加占位符時,我需要檢查很多地方的代碼以使其正常.

                  This can be handled easy if the query is relatively simple (like I posted above), but now I built a query with 5 (!!!) uses of single variable. Each time I add the placeholder I need to check the code in many places to make it OK.

                  有什么設置或調整可以繞過這個嗎?

                  Is there any setting or a tweak to bypass this?

                  推薦答案

                  有什么設置或調整可以繞過這個嗎?

                  Is there any setting or a tweak to bypass this?

                  是的,有.您可以開啟仿真模式,并且可以多次使用同一個占位符.

                  Yes, there is. You can turn emulation mode ON and be able to use the same placeholder multiple times.

                  因此,僅當仿真關閉時才會觀察到所描述的行為.我真的不明白為什么會這樣,但這里是 Wez Furlong(PDO 作者)的解釋:

                  So the described behavior is observed only when the emulation is turned OFF. I don't really understand why it is so but here is an explanation from Wez Furlong (the PDO author):

                  進行更改有兩個原因;首先,如果您在綁定中重復使用相同的變量,則在使用某些驅動程序時可能會導致崩潰.無法保證做正確的事情,并且有時可以將觸發崩潰的方法用作安全漏洞的攻擊媒介.

                  The change was made for two reasons; first and foremost, if you re-use the same variable in a bind, it is possible to induce a crash when using some drivers. It’s not possible to guarantee to do the right thing, and having a way to trigger a crash can sometimes be used as an attack vector for a security exploit.

                  第二個原因是便攜性.一些驅動程序會在內部執行此檢查并出錯.如果您針對不強制執行此操作的驅動程序編寫代碼,那么您的代碼將無法在不強制執行的驅動程序上運行.

                  The second reason is that of portability. Some drivers would internally perform this check and error out. If you code against the drivers that don’t enforce this, then your code won’t work on those that don’t.

                  http://paul-m-jones.com/archives/243#評論-740

                  這篇關于為什么 PDO 不允許多個同名占位符?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)

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

                      • <i id='dRhHm'><tr id='dRhHm'><dt id='dRhHm'><q id='dRhHm'><span id='dRhHm'><b id='dRhHm'><form id='dRhHm'><ins id='dRhHm'></ins><ul id='dRhHm'></ul><sub id='dRhHm'></sub></form><legend id='dRhHm'></legend><bdo id='dRhHm'><pre id='dRhHm'><center id='dRhHm'></center></pre></bdo></b><th id='dRhHm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='dRhHm'><tfoot id='dRhHm'></tfoot><dl id='dRhHm'><fieldset id='dRhHm'></fieldset></dl></div>
                          <bdo id='dRhHm'></bdo><ul id='dRhHm'></ul>
                            <tbody id='dRhHm'></tbody>
                          • <legend id='dRhHm'><style id='dRhHm'><dir id='dRhHm'><q id='dRhHm'></q></dir></style></legend>

                            <tfoot id='dRhHm'></tfoot>

                            主站蜘蛛池模板: 三级黄色大片网站 | 色婷婷综合网站 | 亚洲91视频 | 国产精品久久久99 | 又爽又黄axxx片免费观看 | 亚洲国产午夜 | 91久久精品国产91久久性色tv | 澳门永久av免费网站 | 一区二区在线 | 国产日韩欧美激情 | 另类 综合 日韩 欧美 亚洲 | 成人av电影网 | 玖玖国产精品视频 | 国产黄色小视频在线观看 | 国产精品国产自产拍高清 | 亚洲国产精品成人久久久 | 三级黄色片在线播放 | 国产成人免费网站 | 日本天天色 | 国产精品1区 | 欧美三级在线 | 亚洲精品91 | 亚洲精品在线视频 | 最新国产精品精品视频 | 香蕉视频黄色 | 久久久免费 | 这里只有精品999 | 日本一二三区电影 | 一区二区三区四区在线视频 | 激情六月丁香婷婷 | 99reav| 欧美在线视频一区二区 | 一级a爱片性色毛片免费 | 精品国产一区二区三区成人影院 | 黑人巨大精品欧美一区二区免费 | 青青草一区二区三区 | 欧美日在线 | 狠狠干狠狠插 | 日韩精品免费视频 | 天天干视频 | 国产一区二区欧美 |