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

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

        • <bdo id='cYCaW'></bdo><ul id='cYCaW'></ul>

        <legend id='cYCaW'><style id='cYCaW'><dir id='cYCaW'><q id='cYCaW'></q></dir></style></legend>
      1. <tfoot id='cYCaW'></tfoot>

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

        是否可以將 bind_param 用于 ORDER BY?

        Is it possible to use bind_param for ORDER BY?(是否可以將 bind_param 用于 ORDER BY?)

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

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

                    <tbody id='vqASI'></tbody>

                  本文介紹了是否可以將 bind_param 用于 ORDER BY?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  在我看來,我有一個類似這樣的查詢:

                  In my mind I have a query that goes something like this:

                  $sort = isset($sort) ? sanitize($_sort) : 'id';
                  
                  if ($result = $link->prepare("
                      SELECT id, price
                      FROM items
                      ORDER BY ?
                  "))
                  {
                      $result->bind_param("s", $sort);
                      $result->execute();
                      etc...
                  }
                  

                  當我在不設置排序變量的情況下運行此代碼塊時,它運行時不會出現與在 ORDER BY 子句中使用 ? 相關的錯誤,并且結果集顯示在看起來像帶有ORDER BY id"的結果集.

                  When I run this code block without setting the sort variable it runs without an error relating to the use of the ? in the ORDER BY clause and a result set is displayed in what appears to be a result set with "ORDER BY id".

                  如果我將排序變量設置為price ASC"之類的值,我仍然會得到一個似乎是ORDER BY id"而不是ORDER BY price ASC"的結果集.

                  現在,如果我改變代碼并像這樣運行它:

                  Now, if I alter the code and run it like this:

                  $sort = isset($sort) ? sanitize($_sort) : 'id';
                  
                  if ($result = $link->prepare("
                      SELECT id, price
                      FROM items
                      ORDER BY $sort
                  "))
                  {
                      $result->execute();
                      etc...
                  }
                  

                  它運行正確,結果集與我在 phpMyAdmin 中的查詢相同.

                  It runs correctly, with a result set that is the same as my query in phpMyAdmin.

                  這里到底發生了什么以及為什么查詢沒有按照我最初使用 bind_param 的預期運行.

                  What exactly is going on here and why the query does not run as I initially intended using bind_param.

                  在我看來,它應該可以工作,因為不會出現與此類使用相關的錯誤……但實際上,它似乎不適用于 ORDER BY 子句.這幾乎就像在運行 bind_param 時沒有轉換排序變量一樣.

                  In my mind, it should work because no error comes up relating to such use... But in practice it seems that it does not work for an ORDER BY clause. It's almost like it is not translating the sort variable while running bind_param.

                  對于任何有興趣的人 -

                  For anyone interested -

                  if (isset($sort))
                  {
                      $acceptableSortValues = array('name', 'price ASC', 'price DESC');
                      $sort = sanitize($sort);
                      if (!in_array($sort, $acceptableSortValues))
                      {
                          $sort = 'name';
                      }   
                  }
                  else
                  {
                      $sort = 'name';
                  }
                  
                  if ($result = $link->prepare("
                      SELECT name, price
                      FROM items
                      ORDER BY $sort
                  "))
                  {
                      $result->execute();
                      etc...
                  }
                  

                  推薦答案

                  只有數據可以綁定占位符.

                  列/表名是架構的一部分,不能綁定.(它產生奇怪的結果"而不是簡單地產生錯誤的事實是實現的一個特殊性.)

                  Column/table names are part of the schema and cannot be bound. (The fact that it generates "odd results" instead of simply yielding an error is a peculiarity of the implementation.)

                  我建議使用列名和受控字符串插值的白名單.

                  I would suggest using a white-list of column-names and controlled string interpolation.

                  這篇關于是否可以將 bind_param 用于 ORDER BY?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調用未定義的函數 mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)

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

                        <tbody id='YUt7L'></tbody>
                      • <tfoot id='YUt7L'></tfoot>
                      • <legend id='YUt7L'><style id='YUt7L'><dir id='YUt7L'><q id='YUt7L'></q></dir></style></legend>
                            <bdo id='YUt7L'></bdo><ul id='YUt7L'></ul>
                            <i id='YUt7L'><tr id='YUt7L'><dt id='YUt7L'><q id='YUt7L'><span id='YUt7L'><b id='YUt7L'><form id='YUt7L'><ins id='YUt7L'></ins><ul id='YUt7L'></ul><sub id='YUt7L'></sub></form><legend id='YUt7L'></legend><bdo id='YUt7L'><pre id='YUt7L'><center id='YUt7L'></center></pre></bdo></b><th id='YUt7L'></th></span></q></dt></tr></i><div class="bbpofzs" id='YUt7L'><tfoot id='YUt7L'></tfoot><dl id='YUt7L'><fieldset id='YUt7L'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 不锈钢闸阀_球阀_蝶阀_止回阀_调节阀_截止阀-可拉伐阀门(上海)有限公司 | 金属抛光机-磁悬浮抛光机-磁力研磨机-磁力清洗机 - 苏州冠古科技 | 德州网站制作 - 网站建设设计 - seo排名优化 -「两山建站」 | 油漆辅料厂家_阴阳脚线_艺术漆厂家_内外墙涂料施工_乳胶漆专用防霉腻子粉_轻质粉刷石膏-魔法涂涂 | 深圳装修_店面装修设计_餐厅设计_装修全包价格-尚泰装饰设计 | 浇注料-高铝砖耐火砖-郑州凯瑞得窑炉耐火材料有限公司 | 蓝米云-专注于高性价比香港/美国VPS云服务器及海外公益型免费虚拟主机 | 岩棉切条机厂家_玻璃棉裁条机_水泥基保温板设备-廊坊鹏恒机械 | 日本SMC气缸接头-速度控制阀-日本三菱伺服电机-苏州禾力自动化科技有限公司 | 沈阳真空机_沈阳真空包装机_沈阳大米真空包装机-沈阳海鹞真空包装机械有限公司 | 土壤养分检测仪|土壤水分|土壤紧实度测定仪|土壤墒情监测系统-土壤仪器网 | 油缸定制-液压油缸厂家-无锡大鸿液压气动成套有限公司 | 伺服电机维修、驱动器维修「安川|三菱|松下」伺服维修公司-深圳华创益 | 拉力机-拉力试验机-万能试验机-电子拉力机-拉伸试验机-剥离强度试验机-苏州皖仪实验仪器有限公司 | 安规_综合测试仪,电器安全性能综合测试仪,低压母线槽安规综合测试仪-青岛合众电子有限公司 | 威廉希尔WilliamHill·足球(中国)体育官方网站| 重庆中专|职高|技校招生-重庆中专招生网 | MTK核心板|MTK开发板|MTK模块|4G核心板|4G模块|5G核心板|5G模块|安卓核心板|安卓模块|高通核心板-深圳市新移科技有限公司 | 盘扣式脚手架-附着式升降脚手架-移动脚手架,专ye承包服务商 - 苏州安踏脚手架工程有限公司 | 昆明网络公司|云南网络公司|昆明网站建设公司|昆明网页设计|云南网站制作|新媒体运营公司|APP开发|小程序研发|尽在昆明奥远科技有限公司 | 胶辊硫化罐_胶鞋硫化罐_硫化罐厂家-山东鑫泰鑫智能装备有限公司 意大利Frascold/富士豪压缩机_富士豪半封闭压缩机_富士豪活塞压缩机_富士豪螺杆压缩机 | elisa试剂盒价格-酶联免疫试剂盒-猪elisa试剂盒-上海恒远生物科技有限公司 | 干式磁选机_湿式磁选机_粉体除铁器-潍坊国铭矿山设备有限公司 | 广东风淋室_广东风淋室厂家_广东风淋室价格_广州开源_传递窗_FFU-广州开源净化科技有限公司 | 耐高温风管_耐高温软管_食品级软管_吸尘管_钢丝软管_卫生级软管_塑料波纹管-东莞市鑫翔宇软管有限公司 | 二手回收公司_销毁处理公司_设备回收公司-找回收信息网 | 办公室家具_板式办公家具定制厂家-FMARTS福玛仕办公家具 | 许昌奥仕达自动化设备有限公司| 苗木价格-苗木批发-沭阳苗木基地-沭阳花木-长之鸿园林苗木场 | 河南空气能热水器-洛阳空气能采暖-洛阳太阳能热水工程-洛阳润达高科空气能商行 | 警方提醒:赣州约炮论坛真的安全吗?2025年新手必看的网络交友防坑指南 | 巩义市科瑞仪器有限公司| 齿轮减速电机一体机_蜗轮蜗杆减速马达-德国BOSERL齿轮减速机带电机生产厂家 | 智成电子深圳tdk一级代理-提供TDK电容电感贴片蜂鸣器磁芯lambda电源代理经销,TDK代理商有哪些TDK一级代理商排名查询。-深圳tdk一级代理 | PTFE接头|聚四氟乙烯螺丝|阀门|薄膜|消解罐|聚四氟乙烯球-嘉兴市方圆氟塑制品有限公司 | 建筑消防设施检测系统检测箱-电梯**检测仪器箱-北京宇成伟业科技有限责任公司 | 电动车头盔厂家_赠品头盔_安全帽批发_山东摩托车头盔—临沂承福头盔 | 浩方智通 - 防关联浏览器 - 跨境电商浏览器 - 云雀浏览器 | 电销卡 防封电销卡 不封号电销卡 电话销售卡 白名单电销卡 电销系统 外呼系统 | 清管器,管道清管器,聚氨酯发泡球,清管球 - 承德嘉拓设备 | 精益专家 - 设备管理软件|HSE管理系统|设备管理系统|EHS安全管理系统 |