久久久久久久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>
                            主站蜘蛛池模板: 国产精品69毛片高清亚洲 | 欧美日韩国产一区 | 日本精品一区二区 | 国产成人免费视频网站高清观看视频 | 成人三级视频 | 一区二区三区免费 | 婷婷综合色| 365夜爽爽欧美性午夜免费视频 | 午夜网| 国产精品久久久久久久久久久久冷 | 亚洲美女视频 | 狠狠干天天干 | 国产一区91精品张津瑜 | 精品国产一区二区三区性色av | 欧美亚洲视频在线观看 | aaa精品| 国产综合久久久久久鬼色 | 久久国产精品免费一区二区三区 | 奇米四色在线观看 | 国产精品乱码一区二区三区 | 99亚洲精品 | 手机看片1 | 天天干,夜夜操 | 成人在线视频观看 | 99精品免费在线观看 | 精品九九久久 | 国产日屁 | 久久国产精品免费一区二区三区 | 国产视频久久久久 | 99久久精品国产毛片 | 国产精品久久精品 | 久久精品亚洲欧美日韩精品中文字幕 | 一区二区三区欧美在线 | 91福利影院| 国产精品波多野结衣 | 日韩美av| a在线v| 一级特黄色毛片 | 亚洲福利网站 | 免费同性女女aaa免费网站 | 国产伦精品一区二区三区四区视频 |