久久久久久久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)備好的語句如何工作?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(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.

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

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

                  舉個例子,我在我的代碼下面粘貼了在用戶表中插入新用戶的代碼.那安全嗎?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

                  推薦答案

                  好的,我在這個相關(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 將這個 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ù)庫時,它通常作為字符串發(fā)送.數(shù)據(jù)庫引擎將嘗試解析字符串并將數(shù)據(jù)與指令分開,依賴于引號和語法.因此,如果您發(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)備好的語句如何工作?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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 可滾動游標(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 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動程序)
                      <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 | 五月天综合影院 | 久久久久久久一区 | 欧美精品一区二区三区在线播放 | 婷婷五月色综合 | www.av在线| 欧美日韩久久久 | 国产免费一区二区 | 天天干天天爱天天爽 | 欧美黄色小视频 | 亚洲黄色在线免费观看 | 毛片免费看 | 久久大香 | 美女国内精品自产拍在线播放 | 欧美精品一二区 | 欧美精品一区二区三区在线播放 | jav成人av免费播放 | 一级a爱片久久毛片 | 成年人免费看 | 日韩一区二区在线视频 | 精品一区二区三区电影 | 成人网av | 欧美日韩一区二区在线播放 | 激情 亚洲 | 国产亚洲精品精品国产亚洲综合 | 亚洲天堂男人的天堂 | 久久久久国产精品一区 | 国产欧美精品区一区二区三区 | 久久精品亚洲精品国产欧美kt∨ | 久久精品视频9 | 国产成人精品午夜视频免费 | 中文字幕在线一区二区三区 | 亚洲欧美日韩精品久久亚洲区 | 9191成人精品久久 | 久久99久久99 | 蜜桃视频一区二区三区 | 成人啊啊啊 | 性色av网站 | 国产一伦一伦一伦 |