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

    <bdo id='XyTzn'></bdo><ul id='XyTzn'></ul>
  • <small id='XyTzn'></small><noframes id='XyTzn'>

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

    <tfoot id='XyTzn'></tfoot>

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

        在 PDO 語句中轉義列名

        Escaping column names in PDO statements(在 PDO 語句中轉義列名)
            <tbody id='FnrRo'></tbody>

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

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

                <tfoot id='FnrRo'></tfoot>

                • 本文介紹了在 PDO 語句中轉義列名的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我目前正在構建一個查詢,其中字段/列和值部分可能由用戶輸入的數據組成.

                  I am currently building a query where both the field/column and value parts possibly consist of user inputted data.

                  問題是轉義字段名.我正在使用準備好的語句來正確轉義和引用值,但是在轉義字段名時我遇到了麻煩.

                  The problem is escaping the fieldnames. I'm using prepared statements in order to properly escape and quote the values but when escaping the fieldnames i run into trouble.

                  • mysql_real_escape_string 需要一個 mysql 連接資源以便我們排除
                  • PDO::quote 在字段名周圍添加引號,這使得它們在查詢中也無用
                  • addslashes 有效,但并不安全

                  有人知道在將字段名傳遞給 PDO::prepare 之前將字段名正確插入到查詢中的最佳方法是什么嗎?

                  Anyone has an idea on what the best way is to properly insert the fieldnames into the query before passing it to PDO::prepare?

                  推薦答案

                  ANSI 標準的分隔標識符方式是:

                  The ANSI standard way of doing a delimited identifier is:

                  SELECT "field1" ...
                  

                  如果名稱中有 ",請將其加倍:

                  and if there's a " in the name, double it:

                  SELECT "some""thing" ...
                  

                  不幸的是,這在具有默認設置的 MySQL 中不起作用,因為 MySQL 更喜歡認為雙引號是字符串文字的單引號的替代方案.在這種情況下,您必須使用反引號(如 Bj?rn 所述)和反斜杠轉義.

                  Unfortunately this doesn't work in MySQL with the default settings, because MySQL prefers to think double quotes are an alternative to single quotes for string literals. In this case you have to use backticks (as outlined by Bj?rn) and backslash-escaping.

                  要正確進行反斜杠轉義,您需要 mysql_real_escape_string,因為它依賴于字符集.但這一點沒有實際意義,因為mysql_real_escape_string 和addslashes 都不會轉義反引號.如果您可以確定列名中永遠不會有非 ASCII 字符,您只需手動反斜杠轉義 ` 和 字符即可.

                  To do backslash escaping correctly, you would need mysql_real_escape_string, because it's character-set-dependent. But the point is moot, because neither mysql_real_escape_string nor addslashes escape the backquote character. If you can be sure there will never be non-ASCII characters in the column names you can get away with just manually backslash-escaping the ` and characters.

                  無論如何,這與其他數據庫不兼容.您可以通過設置配置選項 ANSI_QUOTES 來告訴 MySQL 允許 ANSI 語法.類似地,SQL Server 也默認在雙引號上阻塞;它使用另一種語法,即方括號.同樣,您可以使用quoted_identifier"選項將其配置為支持 ANSI 語法.

                  Either way, this isn't compatible with other databases. You can tell MySQL to allow the ANSI syntax by setting the config option ANSI_QUOTES. Similarly, SQL Server also chokes on double quotes by default; it uses yet another syntax, namely square brackets. Again, you can configure it to support the ANSI syntax with the ‘quoted_identifier’ option.

                  總結:如果你只需要 MySQL 兼容性:

                  Summary: if you only need MySQL compatibility:

                  一個.使用反引號并禁止在名稱中使用反引號、反斜杠和空字符,因為轉義它們是不可靠的

                  a. use backquotes and disallow the backquote, backslash and nul character in names because escaping them is unreliable

                  如果您需要跨 DBMS 兼容性,可以:

                  If you need cross-DBMS compatibility, either:

                  B.使用雙引號并要求 MySQL/SQL-Server 用戶適當地更改配置.禁止在名稱中使用雙引號字符(因為 Oracle 無法處理它們甚至轉義).或者,

                  b. use double quotes and require MySQL/SQL-Server users to change the configuration appropriately. Disallow double-quote characters in the name (as Oracle can't handle them even escaped). Or,

                  c.有一個 MySQL vs SQL Server vs Others 的設置,并根據它生成反引號、方括號或雙引號語法.禁止雙引號和反斜杠/反引號/nul.

                  c. have a setting for MySQL vs SQL Server vs Others, and produce either the backquote, square bracket, or double-quote syntax depending on that. Disallow both double-quotes and backslash/backquote/nul.

                  這是您希望數據訪問層具有的功能,但 PDO 沒有.

                  This is something you'd hope the data access layer would have a function for, but PDO doesn't.

                  摘要總結:任意列名都是一個問題,如果你能幫忙,最好避免.

                  Summary of the summary: arbitrary column names are a problem, best avoided if you can help it.

                  總結總結:gnnnnnnnnnnnh.

                  Summary of the summary of the summary: gnnnnnnnnnnnh.

                  這篇關于在 PDO 語句中轉義列名的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)
                  <tfoot id='KOphY'></tfoot>

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

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

                      <tbody id='KOphY'></tbody>

                            主站蜘蛛池模板: 国产精品久久久久久久久久免费看 | 欧美精品中文字幕久久二区 | 天堂一区二区三区 | 懂色中文一区二区三区在线视频 | 毛片a级| 亚洲欧美日韩高清 | 成人国产综合 | 国产中文字幕在线 | 成人欧美一区二区三区黑人孕妇 | 精品国产一区二区三区久久久久久 | 国产午夜精品一区二区三区 | 欧美一级免费看 | 欧美精品a∨在线观看不卡 国产精品久久国产精品 | 婷婷久久精品一区二区 | 国产免费一区二区三区 | 爱爱视频日本 | 99视频免费看 | 国产一区 在线视频 | 欧美精品日韩精品国产精品 | 国产一区二区欧美 | 欧美一级久久久猛烈a大片 日韩av免费在线观看 | 午夜影院在线观看 | 日韩一二区 | 国外成人在线视频 | www.操com | 国产精品一区二区在线 | 欧美一级黄色网 | 国产香蕉视频在线播放 | 午夜视频一区二区 | 奇米视频777| 免费国产视频 | 欧美寡妇偷汉性猛交 | 久久久高清 | 围产精品久久久久久久 | 久久久五月天 | 91超碰在线 | 一区二区三区四区av | 欧美日韩中文国产一区发布 | 一区中文字幕 | 亚洲精品视频在线观看视频 | 午夜影视网 |