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

  • <tfoot id='FuDLb'></tfoot>

        <bdo id='FuDLb'></bdo><ul id='FuDLb'></ul>

      1. <small id='FuDLb'></small><noframes id='FuDLb'>

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

        PDO bindParam 與執行

        PDO bindParam vs. execute(PDO bindParam 與執行)
          <tbody id='uE8xf'></tbody>

      3. <small id='uE8xf'></small><noframes id='uE8xf'>

          • <tfoot id='uE8xf'></tfoot>

              <bdo id='uE8xf'></bdo><ul id='uE8xf'></ul>

                1. <i id='uE8xf'><tr id='uE8xf'><dt id='uE8xf'><q id='uE8xf'><span id='uE8xf'><b id='uE8xf'><form id='uE8xf'><ins id='uE8xf'></ins><ul id='uE8xf'></ul><sub id='uE8xf'></sub></form><legend id='uE8xf'></legend><bdo id='uE8xf'><pre id='uE8xf'><center id='uE8xf'></center></pre></bdo></b><th id='uE8xf'></th></span></q></dt></tr></i><div class="cqlvvhr" id='uE8xf'><tfoot id='uE8xf'></tfoot><dl id='uE8xf'><fieldset id='uE8xf'></fieldset></dl></div>
                  <legend id='uE8xf'><style id='uE8xf'><dir id='uE8xf'><q id='uE8xf'></q></dir></style></legend>
                  本文介紹了PDO bindParam 與執行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我經??吹绞褂?bindParambindValue 和 PDO 的代碼.簡單地將參數傳遞給 execute 是否會因任何原因而皺眉?

                  I often see code using bindParam or bindValue with PDO. Is simply passing arguments to execute frowned upon for any reason?

                  我知道 bindParam 實際上綁定到變量,并且您可以設置與 bind 方法綁定的參數類型,但是如果您只插入字符串怎么辦?

                  I understand that bindParam actually binds to the variables and that you can set the type of parameter being bound with both bind methods, but what if you are only inserting strings?

                  $query = "SELECT col1 FROM t1 WHERE col2 = :col2 AND col3 = :col3 AND col4 = :col4";
                  $pdo->bindValue(':col2', 'col2');
                  $pdo->bindValue(':col3', 'col3');
                  $pdo->bindValue(':col4', 'col4');
                  

                  我經常看到以上內容,但我個人更喜歡:

                  I often see the above, but personally I prefer:

                  $pdo->execute(array(':col2' => 'col2', ':col3' => 'col3', ':col4' => 'col4'));
                  

                  它沒有那么冗長,而且從視覺上看,讓輸入一起進入"查詢對我來說更有意義.但是,我幾乎沒有看到它被使用過.

                  It is not as verbose and visually it makes more sense to me to have the inputs "going in" to the query together. However, I hardly ever see it used.

                  當您不必利用 bind 方法的特殊行為時,是否有理由更喜歡 bind 方法而不是將參數傳遞給 execute ?>

                  Is there a reason to prefer the bind methods over passing parameters to execute when you don't have to take advantage of the special behaviors of the former?

                  推薦答案

                  您可能會發現 bindParam 在您只想將變量引用綁定到查詢中的參數時使用,但也許仍然需要對其進行一些操作,只需要在查詢執行時計算的變量值.它還允許您執行更復雜的操作,例如將參數綁定到存儲過程調用并將返回值更新到綁定變量中.

                  You might find bindParam used when you just want to bind a variable reference to a parameter in the query, but perhaps still need to do some manipulations on it and only want the value of the variable calculated at time of query execution. It also allows you to do more complex things like bind a parameter to a stored procedure call and have the returned value updated into the bound variable.

                  有關更多信息,請參閱bindParam 文檔,bindValue 文檔 和 執行文檔.

                  For more, see the bindParam documentation, bindValue documentation and execute documentation.

                  例如

                  $col1 = 'some_value';
                  $pdo->bindParam(':col1', $col1);
                  $col1 = 'some_other_value';
                  $pdo->execute(); // would use 'some_other_value' for ':col1' parameter
                  

                  bindValue 和將數組傳遞給 execute 的行為與參數值在該點固定并相應地執行 SQL 的方式大致相同.

                  bindValue and passing an array to execute behave in much the same way as the parameter value is fixed at that point and SQL executed accordingly.

                  遵循上面相同的示例,但使用 bindValue

                  Following the same example above, but using bindValue

                  $col1 = 'some_value';
                  $pdo->bindValue(':col1', $col1);
                  $col1 = 'some_other_value';
                  $pdo->execute(); // would use 'some_value' for ':col1' parameter
                  

                  當直接在 execute 中傳遞值時,所有值都被視為字符串(即使提供了整數值).因此,如果您需要強制執行數據類型,則應始終使用 bindValuebindParam.

                  When passing values directly in execute all values are treated as strings (even if integer value is provided). So if you need to enforce data types, you should always use bindValue or bindParam.

                  我認為您可能會看到 bind*execute(array) 使用得更多,因為許多人認為在參數聲明中顯式定義數據類型是更好的編碼實踐.

                  I think you might see bind* used more than execute(array) as many consider it to be better coding practice to explicitly define data types in parameter declarations.

                  這篇關于PDO bindParam 與執行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)
                  <tfoot id='3Fxue'></tfoot>
                    <tbody id='3Fxue'></tbody>
                  1. <small id='3Fxue'></small><noframes id='3Fxue'>

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

                            主站蜘蛛池模板: 电镀整流器_微弧氧化电源_高频电解电源_微弧氧化设备厂家_深圳开瑞节能 | 截齿|煤截齿|采煤机截齿|掘进机截齿|旋挖截齿-山东卓力截齿厂家报价 | 带锯机|木工带锯机圆木推台锯|跑车带锯机|河北茂业机械制造有限公司| | 液氨泵,液化气泵-淄博「亚泰」燃气设备制造有限公司 | 东莞螺丝|东莞螺丝厂|东莞不锈钢螺丝|东莞组合螺丝|东莞精密螺丝厂家-东莞利浩五金专业紧固件厂家 | 青岛美佳乐清洁工程有限公司|青岛油烟管道清洗|酒店|企事业单位|学校工厂厨房|青岛油烟管道清洗 插针变压器-家用电器变压器-工业空调变压器-CD型电抗器-余姚市中驰电器有限公司 | 有源电力滤波装置-电力有源滤波器-低压穿排电流互感器|安科瑞 | 微水泥_硅藻泥_艺术涂料_艺术漆_艺术漆加盟-青岛泥之韵环保壁材 武汉EPS线条_EPS装饰线条_EPS构件_湖北博欧EPS线条厂家 | AGV叉车|无人叉车|AGV智能叉车|AGV搬运车-江西丹巴赫机器人股份有限公司 | 欧版反击式破碎机-欧版反击破-矿山石料破碎生产线-青州奥凯诺机械 | 能耗监测系统-节能监测系统-能源管理系统-三水智能化 | 中开泵,中开泵厂家,双吸中开泵-山东博二泵业有限公司 | 泰安塞纳春天装饰公司【网站】 | 密集架-手摇-智能-移动-价格_内蒙古档案密集架生产厂家 | 广州中央空调回收,二手中央空调回收,旧空调回收,制冷设备回收,冷气机组回收公司-广州益夫制冷设备回收公司 | 小型气象站_车载气象站_便携气象站-山东风途物联网 | 留学生辅导网-在线课程论文辅导-留学生挂科申诉机构 | 铣刨料沥青破碎机-沥青再生料设备-RAP热再生混合料破碎筛分设备 -江苏锡宝重工 | 微水泥_硅藻泥_艺术涂料_艺术漆_艺术漆加盟-青岛泥之韵环保壁材 武汉EPS线条_EPS装饰线条_EPS构件_湖北博欧EPS线条厂家 | 杭州火蝠电商_京东代运营_拼多多全托管代运营【天猫代运营】 | 地图标注-手机导航电子地图如何标注-房地产商场地图标记【DiTuBiaoZhu.net】 | 12cr1mov无缝钢管切割-15crmog无缝钢管切割-40cr无缝钢管切割-42crmo无缝钢管切割-Q345B无缝钢管切割-45#无缝钢管切割 - 聊城宽达钢管有限公司 | 防堵吹扫装置-防堵风压测量装置-电动操作显示器-兴洲仪器 | 生物制药洁净车间-GMP车间净化工程-食品净化厂房-杭州波涛净化设备工程有限公司 | 郑州大巴车出租|中巴车租赁|旅游大巴租车|包车|郑州旅游大巴车租赁有限公司 | 精密交叉滚子轴承厂家,转盘轴承,YRT转台轴承-洛阳千协轴承 | 丹尼克尔拧紧枪_自动送钉机_智能电批_柔性振动盘_螺丝供料器品牌 | 一体化隔油提升设备-餐饮油水分离器-餐厨垃圾处理设备-隔油池-盐城金球环保产业发展有限公司 | 在线钠离子分析仪-硅酸根离子浓度测定仪-油液水分测定仪价格-北京时代新维测控设备有限公司 | 智能汉显全自动量热仪_微机全自动胶质层指数测定仪-鹤壁市科达仪器仪表有限公司 | 北京办公室装修,办公室设计,写字楼装修-北京金视觉装饰工程公司 北京成考网-北京成人高考网 | 家用净水器代理批发加盟_净水机招商代理_全屋净水器定制品牌_【劳伦斯官网】 | 缠膜机|缠绕包装机|无纺布包装机-济南达伦特机械设备有限公司 | 轻型地埋电缆故障测试仪,频响法绕组变形测试仪,静荷式卧式拉力试验机-扬州苏电 | 电缆接头_防水接头_电缆防水接头 - 乐清市新豪电气有限公司 | 工业车间焊接-整体|集中除尘设备-激光|等离子切割机配套除尘-粉尘烟尘净化治理厂家-山东美蓝环保科技有限公司 | 车间除尘设备,VOCs废气处理,工业涂装流水线,伸缩式喷漆房,自动喷砂房,沸石转轮浓缩吸附,机器人喷粉线-山东创杰智慧 | 优宝-汽车润滑脂-轴承润滑脂-高温齿轮润滑油脂厂家 | 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | 电动垃圾车,垃圾清运车-江苏速利达机车有限公司 | 单螺旋速冻机-双螺旋-流态化-隧道式-食品速冻机厂家-广州冰泉制冷 |