pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

      • <bdo id='2KwoY'></bdo><ul id='2KwoY'></ul>
      <tfoot id='2KwoY'></tfoot>

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

        <small id='2KwoY'></small><noframes id='2KwoY'>

      2. 使用 Zend_Db 類避免 MySQL 注入

        avoiding MySQL injections with the Zend_Db class(使用 Zend_Db 類避免 MySQL 注入)
        <legend id='vEy85'><style id='vEy85'><dir id='vEy85'><q id='vEy85'></q></dir></style></legend>

            • <bdo id='vEy85'></bdo><ul id='vEy85'></ul>
              <tfoot id='vEy85'></tfoot>
                <tbody id='vEy85'></tbody>

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

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

                1. 本文介紹了使用 Zend_Db 類避免 MySQL 注入的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我目前使用 Zend_Db 來管理我的查詢.我已經編寫了可以執行如下查詢的代碼:

                  I currently use Zend_Db to manage my queries. I've written already code that preforms queries like the one below:

                  $handle->select()->from('user_id')
                                     ->where('first_name=?', $id)
                                     ->where('last_name=?', $lname)
                  

                  假設 Zend_Db 會,我在沒有清理輸入的情況下完成了這項工作.Zend 會這樣做嗎?

                  I've done this without sanitizing the input, assuming Zend_Db will. Does Zend do this?

                  另一個問題:Zend_Db 是否清理 insert('table', $data)update 查詢?

                  Another question: Does Zend_Db sanitize insert('table', $data) and update queries?

                  謝謝.

                  推薦答案

                  當我擔任該項目的團隊負責人(直到 1.0 版)時,我在 Zend Framework 中編寫了大量用于數據庫參數和引用的代碼.

                  I wrote a lot of the code for database parameters and quoting in Zend Framework while I was the team lead for the project (up to version 1.0).

                  我盡可能鼓勵最佳實踐,但我必須在易用性和易用性之間取得平衡.

                  I tried to encourage best practices where possible, but I had to strike a balance with ease of use.

                  請注意,您始終可以檢查 Zend_Db_Select 對象的字符串值,以查看它如何決定進行引用.

                  Note that you can always examine the string value of a Zend_Db_Select object, to see how it has decided to do quoting.

                  print $select; // invokes __toString() method
                  

                  您也可以使用 Zend_Db_Profiler 檢查由 Zend_Db 代表您運行的 SQL.

                  Also you can use the Zend_Db_Profiler to inspect the SQL that is run on your behalf by Zend_Db.

                  $db->getProfiler()->setEnabled(true);
                  $db->update( ... );
                  print $db->getProfiler()->getLastQueryProfile()->getQuery(); 
                  print_r $db->getProfiler()->getLastQueryProfile()->getQueryParams(); 
                  $db->getProfiler()->setEnabled(false);
                  

                  以下是您的具體問題的一些答案:

                  Here are some answers to your specific questions:

                  • Zend_Db_Select::where('last_name=?', $lname)

                  值被適當引用.雖然?"看起來像一個參數占位符,但在這個方法中,參數實際上被適當地引用和插入.所以它不是一個真正的查詢參數.實際上,以下兩條語句產生的查詢與上述用法完全相同:

                  Values are quoted appropriately. Although the "?" looks like a parameter placeholder, in this method the argument is actually quoted appropriately and interpolated. So it's not a true query parameter. In fact, the following two statements produce exactly the same query as the above usage:

                  $select->where( $db->quoteInto('last_name=?', $lname) );
                  $select->where( 'last_name=' . $db->quote($lname) );
                  

                  然而,如果您傳遞的參數是 Zend_Db_Expr 類型的對象,則它不會被引用.您應對 SQL 注入風險負責,因為它是逐字插入的,以支持表達式值:

                  However, if you pass a parameter that is an object of type Zend_Db_Expr, then it's not quoted. You're responsible for SQL injection risks, because it's interpolated verbatim, to support expression values:

                  $select->where('last_modified < ?', new Zend_Db_Expr('NOW()'))
                  

                  該表達式的任何其他需要引用或分隔的部分是您的責任.例如,如果您將任何 PHP 變量插入到表達式中,安全是您的責任.如果您的列名是 SQL 關鍵字,您需要自己用 quoteIdentifier() 分隔它們.示例:

                  Any other part of that expression that needs to be quoted or delimited is your responsibility. E.g., if you interpolate any PHP variables into the expression, safety is your responsibility. If you have column names that are SQL keywords, you need to delimit them yourself with quoteIdentifier(). Example:

                  $select->where($db->quoteIdentifier('order').'=?', $myVariable)
                  

                2. Zend_Db_Adapter_Abstract::insert( array('colname' => 'value') )

                  表名和列名是分隔的,除非你關閉AUTO_QUOTE_IDENTIFIERS.

                  Table name and column names are delimited, unless you turn off AUTO_QUOTE_IDENTIFIERS.

                  值被參數化為真正的查詢參數(未插入).除非值是一個 Zend_Db_Expr 對象,在這種情況下它是逐字插入的,所以你可以插入表達式或 NULL 或其他什么.

                  Values are parameterized as true query parameters (not interpolated). Unless the value is a Zend_Db_Expr object, in which case it's interpolated verbatim, so you can insert expressions or NULL or whatever.

                  Zend_Db_Adapter_Abstract::update( array('colname' => 'value'), $where )

                  表名和列名是分隔的,除非你關閉AUTO_QUOTE_IDENTIFIERS.

                  Table name and column names are delimited, unless you turn off AUTO_QUOTE_IDENTIFIERS.

                  值是參數化的,除非它們是 Zend_Db_Expr 對象,如 insert() 方法.

                  Values are parameterized, unless they are Zend_Db_Expr objects, as in insert() method.

                  $where 參數根本沒有被過濾,因此您應對該參數中的任何 SQL 注入風險負責.您可以使用 quoteInto() 方法來幫助更方便地引用.

                  The $where argument is not filtered at all, so you're responsible for any SQL injection risks in that one. You can make use of the quoteInto() method to help make quoting more convenient.

                  這篇關于使用 Zend_Db 類避免 MySQL 注入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!
                3. 相關文檔推薦

                  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 找不到驅動程序)
                  <legend id='LQDB4'><style id='LQDB4'><dir id='LQDB4'><q id='LQDB4'></q></dir></style></legend>
                  <tfoot id='LQDB4'></tfoot>

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

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

                          1. 主站蜘蛛池模板: 电气控制系统集成商-PLC控制柜变频控制柜-非标自动化定制-电气控制柜成套-NIDEC CT变频器-威肯自动化控制 | 运动木地板_体育木地板_篮球馆木地板_舞台木地板-实木运动地板厂家 | 北京租车牌|京牌指标租赁|小客车指标出租 | 除甲醛公司-甲醛检测-广西雅居环境科技有限公司 | 工业胀紧套_万向节联轴器_链条-规格齐全-型号选购-非标订做-厂家批发价格-上海乙谛精密机械有限公司 | 宿松新闻网 宿松网|宿松在线|宿松门户|安徽宿松(直管县)|宿松新闻综合网站|宿松官方新闻发布 | 档案密集架_电动密集架_移动密集架_辽宁档案密集架-盛隆柜业厂家现货批发销售价格公道 | 佛山市钱丰金属不锈钢蜂窝板定制厂家|不锈钢装饰线条|不锈钢屏风| 电梯装饰板|不锈钢蜂窝板不锈钢工艺板材厂家佛山市钱丰金属制品有限公司 | 寮步纸箱厂_东莞纸箱厂 _东莞纸箱加工厂-东莞市寮步恒辉纸制品厂 | 服务器之家 - 专注于服务器技术及软件下载分享 | 档案密集架_电动密集架_移动密集架_辽宁档案密集架-盛隆柜业厂家现货批发销售价格公道 | 水环真空泵厂家,2bv真空泵,2be真空泵-淄博真空设备厂 | 高精度-恒温冷水机-螺杆式冰水机-蒸发冷冷水机-北京蓝海神骏科技有限公司 | 江苏远邦专注皮带秤,高精度皮带秤,电子皮带秤研发生产 | 学校用栓剂模,玻璃瓶轧盖钳,小型安瓿熔封机,实验室安瓿熔封机-长沙中亚制药设备有限公司 | 冰晶石|碱性嫩黄闪蒸干燥机-有机垃圾烘干设备-草酸钙盘式干燥机-常州市宝康干燥 | 螺杆真空泵_耐腐蚀螺杆真空泵_水环真空泵_真空机组_烟台真空泵-烟台斯凯威真空 | 金刚网,金刚网窗纱,不锈钢网,金刚网厂家- 河北萨邦丝网制品有限公司 | 智慧物联网行业一站式解决方案提供商-北京东成基业 | 杭州用友|用友软件|用友财务软件|用友ERP系统--杭州协友软件官网 | 档案密集架_电动密集架_移动密集架_辽宁档案密集架-盛隆柜业厂家现货批发销售价格公道 | 振动台-振动试验台-振动冲击台-广东剑乔试验设备有限公司 | 上海公众号开发-公众号代运营公司-做公众号的公司企业服务商-咏熠软件 | 专业深孔加工_东莞深孔钻加工_东莞深孔钻_东莞深孔加工_模具深孔钻加工厂-东莞市超耀实业有限公司 | 厌氧反应器,IC厌氧反应器,厌氧三相分离器-山东创博环保科技有限公司 | 新型游乐设备,360大摆锤游乐设备「诚信厂家」-山东方鑫游乐设备 新能源汽车电池软连接,铜铝复合膜柔性连接,电力母排-容发智能科技(无锡)有限公司 | 动力配电箱-不锈钢配电箱-高压开关柜-重庆宇轩机电设备有限公司 聚天冬氨酸,亚氨基二琥珀酸四钠,PASP,IDS - 远联化工 | 恒湿机_除湿加湿一体机_恒湿净化消毒一体机厂家-杭州英腾电器有限公司 | 月嫂_保姆_育婴_催乳_母婴护理_产后康复_养老护理-吉祥到家家政 硫酸亚铁-聚合硫酸铁-除氟除磷剂-复合碳源-污水处理药剂厂家—长隆科技 | 法兰连接型电磁流量计-蒸汽孔板节流装置流量计-北京凯安达仪器仪表有限公司 | 深圳宣传片制作-企业宣传视频制作-产品视频拍摄-产品动画制作-短视频拍摄制作公司 | 搅拌磨|搅拌球磨机|循环磨|循环球磨机-无锡市少宏粉体科技有限公司 | 耐压仪-高压耐压仪|徐吉电气| GAST/BRIWATEC/CINCINNATI/KARL-KLEIN/ZIEHL-ABEGG风机|亚喜科技 | 金环宇|金环宇电线|金环宇电缆|金环宇电线电缆|深圳市金环宇电线电缆有限公司|金环宇电缆集团 | 短信营销平台_短信群发平台_106短信发送平台-河南路尚 | 光环国际-新三板公司_股票代码:838504 | 镀锌方管,无缝方管,伸缩套管,方矩管_山东重鑫致胜金属制品有限公司 | 杭州网络公司_百度SEO优化-外贸网络推广_抖音小程序开发-杭州乐软科技有限公司 | 黄石东方妇产医院_黄石妇科医院哪家好_黄石无痛人流医院 | 防爆鼓风机-全风-宏丰鼓风机-上海梁瑾机电设备有限公司 |