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

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

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

          <bdo id='TpLSJ'></bdo><ul id='TpLSJ'></ul>
      2. <legend id='TpLSJ'><style id='TpLSJ'><dir id='TpLSJ'><q id='TpLSJ'></q></dir></style></legend>

        為什么需要在bindParam()中指定參數類型?

        Why do we need to specify the parameter type in bindParam()?(為什么需要在bindParam()中指定參數類型?)
          <tbody id='WqO2x'></tbody>

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

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

            <legend id='WqO2x'><style id='WqO2x'><dir id='WqO2x'><q id='WqO2x'></q></dir></style></legend>
              <tfoot id='WqO2x'></tfoot>

                • <bdo id='WqO2x'></bdo><ul id='WqO2x'></ul>
                  本文介紹了為什么需要在bindParam()中指定參數類型?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有點困惑,為什么我們需要指定我們在 Php 中的 PDO 中的 bindParam() 函數中傳遞的數據類型.例如這個查詢:

                  I am a bit confuse as to why we need to specify the type of data that we pass in the bindParam() function in PDO in Php. For example this query:

                  $calories = 150; 
                  $colour = 'red';
                  $sth = $dbh->prepare('SELECT name, colour, calories
                  FROM fruit
                  WHERE calories < ? AND colour = ?');
                  $sth->bindParam(1, $calories, PDO::PARAM_INT); 
                  $sth->bindParam(2, $colour, PDO::PARAM_STR, 12);
                  $sth->execute();
                  

                  如果我不指定第三個參數,是否存在安全風險.我的意思是如果我只是在 bindParam() 中做:

                  Is there a security risk if I do not specify the 3rd parameter. I mean if I just do in the bindParam():

                  $sth->bindParam(1, $calories); 
                  $sth->bindParam(2, $colour);
                  

                  推薦答案

                  對類型使用 bindParam() 可以被認為更安全,因為它允許更嚴格的驗證,進一步防止 SQL 注入.但是,如果您不這樣做,我不會說會涉及真正 安全風險,因為更多的是您執行了prepared statement 比類型驗證更能防止 SQL 注入.實現此目的的更簡單方法是簡單地將數組傳遞給 execute() 函數,而不是使用 bindParam(),如下所示:

                  Using bindParam() with types could be considered safer, because it allows for stricter verification, further preventing SQL injections. However, I wouldn't say there is a real security risk involved if you don't do it like that, as it is more the fact that you do a prepared statement that protects from SQL injections than type verification. A simpler way to achieve this is by simply passing an array to the execute() function instead of using bindParam(), like this:

                  $calories = 150; 
                  $colour = 'red';
                  
                  $sth = $dbh->prepare('SELECT name, colour, calories
                                        FROM fruit
                                        WHERE calories < :calories AND colour = :colour');
                  
                  $sth->execute(array(
                      'calories' => $calories,
                      'colour' => $colour
                  ));
                  

                  您沒有義務使用字典,您也可以像使用問號一樣使用字典,然后將其按相同的順序放入數組中.然而,即使這很完美,我還是建議養成使用第一個的習慣,因為一旦達到一定數量的參數,這種方法就會變得一團糟.為了完整起見,這里是它的樣子:

                  You're not obligated to use a dictionary, you can also do it just like you did with questionmarks and then put it in the same order in the array. However, even if this works perfectly, I'd recommend making a habit of using the first one, since this method is a mess once you reach a certain number of parameters. For the sake of being complete, here's what it looks like:

                  $calories = 150; 
                  $colour = 'red';
                  
                  $sth = $dbh->prepare('SELECT name, colour, calories
                                        FROM fruit
                                        WHERE calories < ? AND colour = ?');
                  
                  $sth->execute(array($calories, $colour));
                  

                  這篇關于為什么需要在bindParam()中指定參數類型?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)
                    <tbody id='RmqxX'></tbody>

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

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

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

                          <tfoot id='RmqxX'></tfoot>

                            <bdo id='RmqxX'></bdo><ul id='RmqxX'></ul>
                            主站蜘蛛池模板: av成人在线观看 | www.youjizz.com日韩| 99热精品在线观看 | 四虎在线观看 | 999精品在线观看 | 日韩中文视频 | 亚洲一区二区电影网 | 人人做人人澡人人爽欧美 | 青青久在线视频 | 搞av.com | 国产精品视频网 | 成人黄色电影免费 | 成人在线电影网站 | 国产在线1区 | 啪啪免费 | 中文字幕动漫成人 | 日本精品一区 | 成人免费网站视频 | 国产精品久久久久久久免费大片 | 天天天堂| 亚洲狠狠 | 1区2区视频 | 成年人在线观看 | 亚洲精品一级 | 国产激情偷乱视频一区二区三区 | 国产成人免费视频网站视频社区 | 久久一二| 国产精品久久久久久一区二区三区 | 91色网站 | 精品在线一区二区 | 一区二区三区亚洲精品国 | 精品国产乱码久久久久久牛牛 | a级大片免费观看 | 精品国产乱码久久久久久牛牛 | 久久色视频 | 亚洲高清av在线 | 久久久精品网 | 国产亚洲精品久久久久久豆腐 | 亚洲精品福利在线 | 久久久男人的天堂 | 日本黄色激情视频 |