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

    1. <tfoot id='SRpaX'></tfoot>

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

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

        <legend id='SRpaX'><style id='SRpaX'><dir id='SRpaX'><q id='SRpaX'></q></dir></style></legend>
        • <bdo id='SRpaX'></bdo><ul id='SRpaX'></ul>

        在 PHP 中,PDO 如何防止 SQL 注入?準備好的語句如

        In PHP, how does PDO protect from SQL injections? How do prepared statements work?(在 PHP 中,PDO 如何防止 SQL 注入?準備好的語句如何工作?)
        • <bdo id='ETdP8'></bdo><ul id='ETdP8'></ul>
        • <i id='ETdP8'><tr id='ETdP8'><dt id='ETdP8'><q id='ETdP8'><span id='ETdP8'><b id='ETdP8'><form id='ETdP8'><ins id='ETdP8'></ins><ul id='ETdP8'></ul><sub id='ETdP8'></sub></form><legend id='ETdP8'></legend><bdo id='ETdP8'><pre id='ETdP8'><center id='ETdP8'></center></pre></bdo></b><th id='ETdP8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ETdP8'><tfoot id='ETdP8'></tfoot><dl id='ETdP8'><fieldset id='ETdP8'></fieldset></dl></div>

            <tbody id='ETdP8'></tbody>

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

        • <legend id='ETdP8'><style id='ETdP8'><dir id='ETdP8'><q id='ETdP8'></q></dir></style></legend>

              • <tfoot id='ETdP8'></tfoot>
                  本文介紹了在 PHP 中,PDO 如何防止 SQL 注入?準備好的語句如何工作?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我了解保護數據庫免受 SQL 注入的正確方法是使用準備好的語句.我想了解如何準備好的語句保護我的數據庫.

                  I understand the right way to protect a db from SQL injection is by using prepared statements. I would like to understand how prepared statements protect my db.

                  對于初學者來說,準備好的語句是否與參數化查詢"相同?

                  For starters, are prepared statements the same thing as "parameterised queries"?

                  舉個例子,我在我的代碼下面粘貼了在用戶表中插入新用戶的代碼.那安全嗎?PDO 如何工作以確保其安全?還需要做些什么來保護數據庫免受注入嗎?

                  As an example, I'm pasting below my code for the insertion of a new user in a user table. Is that secure? How does PDO work to make it secure? Does anything more needs to be done to secure the db from injection?

                  在Class_DB.php"中:

                  In 'Class_DB.php':

                  class DB {
                   private $dbHost;
                   private $dbName;
                   private $dbUser;
                   private $dbPassword;   
                   function __construct($dbHost, $dbName, $dbUser, $dbPassword) {
                    $this->dbHost=$dbHost;
                    $this->dbName=$dbName;
                    $this->dbUser=$dbUser;
                    $this->dbPassword=$dbPassword;
                   }
                   function createConnexion() {
                    return new PDO("mysql:host=$this->dbHost;dbName=$this->dbName", $this->dbUser, $this->dbPassword);
                   }
                  }
                  

                  在DAO_User.php"中:

                  In 'DAO_User.php':

                  require_once('Class_DB.php');
                  
                  class DAO_User {
                   private $dbInstance;
                   function __construct($dbInstance){
                    $this->dbInstance=$dbInstance;
                   }
                   function createUser($user){
                    $dbConnection=$this->dbInstance->createConnexion();
                    $query=$dbConnection->prepare("INSERT INTO users (userName, hashedPassword, userEmail) VALUES (?,?,?)");
                    $query->bindValue(1, $user->userName);
                    $query->bindValue(2, $user->hashedPassword);
                    $query->bindValue(3, $user->userEmail);
                    $query->execute();
                   }
                  }
                  

                  謝謝,

                  JDelage

                  推薦答案

                  好的,我在這個相關問題中找到了我的問題的答案:PDO 準備好的語句是否足以防止 SQL 注入?

                  Ok, I found the answer to my question in this related question: Are PDO prepared statements sufficient to prevent SQL injection?

                  感謝 Haim 將這個 Q 指向我.

                  Thanks to Haim for pointing this Q to me.

                  在非技術術語中,以下是準備好的語句如何防止注入:

                  In non technical terms, here is how prepared statements protect from injection:

                  當查詢發送到數據庫時,它通常作為字符串發送.數據庫引擎將嘗試解析字符串并將數據與指令分開,依賴于引號和語法.因此,如果您發送SELECT * WHERE '用戶提交的數據' EQUALS '表行名稱',引擎將能夠解析指令.

                  When a query is sent to a data base, it's typically sent as a string. The db engine will try to parse the string and separate the data from the instructions, relying on quote marks and syntax. So if you send "SELECT * WHERE 'user submitted data' EQUALS 'table row name', the engine will be able to parse the instruction.

                  如果您允許用戶輸入將在用戶提交的數據"中發送的內容,那么他??們可以在其中包含諸如..."或IF 1=1 ERASE DATABASE"之類的內容.數據庫引擎將無法解析this 并將上述內容作為指令而不是無意義的字符串.

                  If you allow a user to enter what will be sent inside 'user submitted data', then they can include in this something like '..."OR IF 1=1 ERASE DATABASE'. The db engine will have trouble parsing this and will take the above as an instruction rather than a meaningless string.

                  PDO 的工作方式是將指令 (prepare("INSERT INTO ...)) 和數據分開發送.數據是分開發送的,清楚地理解為數據和數據而已.db 引擎沒有甚至嘗試分析數據字符串的內容,看看它是否包含指令,并且不考慮任何潛在的破壞性代碼片段.

                  The way PDO works is that it sends separately the instruction (prepare("INSERT INTO ...)) and the data. The data is sent separately, clearly understood as being data and data only. The db engine doesn't even try to analyze the content of the data string to see if it contains instructions, and any potentially damaging code snipet is not considered.

                  這篇關于在 PHP 中,PDO 如何防止 SQL 注入?準備好的語句如何工作?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)
                      <legend id='2tFV2'><style id='2tFV2'><dir id='2tFV2'><q id='2tFV2'></q></dir></style></legend>

                        <bdo id='2tFV2'></bdo><ul id='2tFV2'></ul>

                      • <small id='2tFV2'></small><noframes id='2tFV2'>

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

                            主站蜘蛛池模板: 成年人黄色一级毛片 | 亚洲国产成人精品女人久久久野战 | 久久久精品一区二区 | 在线午夜| 国产一级在线观看 | 欧美国产激情 | 日日夜夜草| 欧美成人h版在线观看 | 91综合网 | 国产精品一区久久久久 | 搞av.com| 国产视频在线观看一区二区三区 | 毛片网站免费观看 | 精品视频免费 | 日韩午夜一区二区三区 | 日韩精品一区二区三区中文在线 | 精品国产18久久久久久二百 | 亚洲网一区| 天天干天天操天天爽 | 亚洲综合大片69999 | 亚洲精品中文字幕 | 涩色视频在线观看 | 伊人久久一区二区 | 久久久久久久久久久久久久久久久久久久 | 欧美成人免费在线 | 日本免费黄色 | 日韩精品在线视频 | 激情欧美日韩一区二区 | 亚洲精品久久久久久久久久久久久 | 日本超碰 | 国产成人精品一区二区三区网站观看 | 四虎在线观看 | 99这里只有精品视频 | 噜久寡妇噜噜久久寡妇 | 成人精品一区二区三区中文字幕 | 黄色网址在线免费播放 | 亚洲午夜小视频 | 国产精品成人一区二区 | 久久另类| 欧美日韩精品中文字幕 | 91一区二区三区 |