久久久久久久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()中指定參數(shù)類型?

        Why do we need to specify the parameter type in bindParam()?(為什么需要在bindParam()中指定參數(shù)類型?)
          <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()中指定參數(shù)類型?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我有點(diǎn)困惑,為什么我們需要指定我們?cè)?Php 中的 PDO 中的 bindParam() 函數(shù)中傳遞的數(shù)據(jù)類型.例如這個(gè)查詢:

                  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();
                  

                  如果我不指定第三個(gè)參數(shù),是否存在安全風(fēng)險(xiǎn).我的意思是如果我只是在 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);
                  

                  推薦答案

                  對(duì)類型使用 bindParam() 可以被認(rèn)為更安全,因?yàn)樗试S更嚴(yán)格的驗(yàn)證,進(jìn)一步防止 SQL 注入.但是,如果您不這樣做,我不會(huì)說(shuō)會(huì)涉及真正 安全風(fēng)險(xiǎn),因?yàn)楦嗟氖悄鷪?zhí)行了prepared statement 比類型驗(yàn)證更能防止 SQL 注入.實(shí)現(xiàn)此目的的更簡(jiǎn)單方法是簡(jiǎn)單地將數(shù)組傳遞給 execute() 函數(shù),而不是使用 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
                  ));
                  

                  您沒(méi)有義務(wù)使用字典,您也可以像使用問(wèn)號(hào)一樣使用字典,然后將其按相同的順序放入數(shù)組中.然而,即使這很完美,我還是建議養(yǎng)成使用第一個(gè)的習(xí)慣,因?yàn)橐坏┻_(dá)到一定數(shù)量的參數(shù),這種方法就會(huì)變得一團(tuán)糟.為了完整起見(jiàn),這里是它的樣子:

                  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));
                  

                  這篇關(guān)于為什么需要在bindParam()中指定參數(shù)類型?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(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)程序)
                    <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一区在线 | 久久精品视频国产 | 不卡在线视频 | 丰满女人裸体淫交 | 久久久久久久久久国产 | 韩国精品一区 | 国产成人一区二区 | 中文字幕在线看 | 深夜福利av | 在线看片a | 日韩av免费播放 | 一级片在线视频 | 国产又爽又黄免费视频 | 四虎成人精品 | 日韩欧美中文 | 玖玖色资源 | 成人av一区| 一二三四区在线观看 | 99午夜 | 国产在线一区二区三区 | 免费爱爱网站 | 欧美色婷婷 | 午夜影院福利 | 亚洲天堂视频在线 | 精品一区在线播放 | 毛片在线免费 | 最近中文字幕在线观看 | 一级看片免费视频 | 91蜜桃婷婷狠狠久久综合9色 | 日韩欧美三级 | 日韩a在线观看 | 亚洲精品小视频 | 日韩精品久久久 | 男人爱看的网站 | 中文在线观看免费网站 | 欧美理论片在线观看 | 亚洲人在线 | 视频一二三区 | 在线免费观看av网站 |