久久久久久久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 注入?準(zhǔn)備好的語句如

        In PHP, how does PDO protect from SQL injections? How do prepared statements work?(在 PHP 中,PDO 如何防止 SQL 注入?準(zhǔn)備好的語句如何工作?)
        • <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 注入?準(zhǔn)備好的語句如何工作?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我了解保護(hù)數(shù)據(jù)庫免受 SQL 注入的正確方法是使用準(zhǔn)備好的語句.我想了解如何準(zhǔn)備好的語句保護(hù)我的數(shù)據(jù)庫.

                  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.

                  對(duì)于初學(xué)者來說,準(zhǔn)備好的語句是否與參數(shù)化查詢"相同?

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

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

                  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

                  推薦答案

                  好的,我在這個(gè)相關(guān)問題中找到了我的問題的答案:PDO 準(zhǔn)備好的語句是否足以防止 SQL 注入?

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

                  感謝 Haim 將這個(gè) Q 指向我.

                  Thanks to Haim for pointing this Q to me.

                  在非技術(shù)術(shù)語中,以下是準(zhǔn)備好的語句如何防止注入:

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

                  當(dāng)查詢發(fā)送到數(shù)據(jù)庫時(shí),它通常作為字符串發(fā)送.數(shù)據(jù)庫引擎將嘗試解析字符串并將數(shù)據(jù)與指令分開,依賴于引號(hào)和語法.因此,如果您發(fā)送SELECT * WHERE '用戶提交的數(shù)據(jù)' 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.

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

                  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 ...)) 和數(shù)據(jù)分開發(fā)送.數(shù)據(jù)是分開發(fā)送的,清楚地理解為數(shù)據(jù)和數(shù)據(jù)而已.db 引擎沒有甚至嘗試分析數(shù)據(jù)字符串的內(nèi)容,看看它是否包含指令,并且不考慮任何潛在的破壞性代碼片段.

                  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.

                  這篇關(guān)于在 PHP 中,PDO 如何防止 SQL 注入?準(zhǔn)備好的語句如何工作?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動(dòng)游標(biāo)不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術(shù)方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個(gè)值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動(dòng)程序)
                      <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>

                            主站蜘蛛池模板: 日韩精品免费在线观看 | 午夜免费福利视频 | 色视频www在线播放国产人成 | a毛片大片 | 深夜福利影院 | 成年人免费看视频 | 中文字幕永久在线 | 久久一级片| 日韩精品视频免费在线观看 | 欧美视频在线观看一区 | 91精品久久香蕉国产线看观看 | 国产精品一区二区三区免费 | 日韩三级精品 | 国产福利网| 九九国产精品视频 | 欧美在线观看一区二区 | 91亚洲成人 | 久久久久久国产精品 | 最新日韩av| 成人玩具h视频 | 四虎免费在线观看 | 99久久久| 97视频在线观看免费 | 中文字幕永久 | 九九热在线视频 | 天天操天天干天天操 | 激情四射网站 | 午夜精品一区二区三区在线视频 | 四虎永久网址 | 日产毛片 | 欧美不卡视频 | 在线成人免费视频 | 欧美激情综合 | 欧美香蕉视频 | 久久免费看片 | 91插插插插插 | 久久久久久久影院 | 欧美高清在线 | 欧美a在线 | 99一区二区三区 | 国产午夜三级 |