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

        <bdo id='7kqbz'></bdo><ul id='7kqbz'></ul>
    1. <small id='7kqbz'></small><noframes id='7kqbz'>

    2. <legend id='7kqbz'><style id='7kqbz'><dir id='7kqbz'><q id='7kqbz'></q></dir></style></legend>

    3. <i id='7kqbz'><tr id='7kqbz'><dt id='7kqbz'><q id='7kqbz'><span id='7kqbz'><b id='7kqbz'><form id='7kqbz'><ins id='7kqbz'></ins><ul id='7kqbz'></ul><sub id='7kqbz'></sub></form><legend id='7kqbz'></legend><bdo id='7kqbz'><pre id='7kqbz'><center id='7kqbz'></center></pre></bdo></b><th id='7kqbz'></th></span></q></dt></tr></i><div class="oz8vyps" id='7kqbz'><tfoot id='7kqbz'></tfoot><dl id='7kqbz'><fieldset id='7kqbz'></fieldset></dl></div>
      <tfoot id='7kqbz'></tfoot>
    4. 如果在循環中使用 MySQLi 準備好的語句,我什么時

      When do I call bind_param if using MySQLi prepared statements in a loop?(如果在循環中使用 MySQLi 準備好的語句,我什么時候調用 bind_param ?)

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

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

            • <bdo id='rHrs7'></bdo><ul id='rHrs7'></ul>
              <tfoot id='rHrs7'></tfoot>
                <tbody id='rHrs7'></tbody>
              <i id='rHrs7'><tr id='rHrs7'><dt id='rHrs7'><q id='rHrs7'><span id='rHrs7'><b id='rHrs7'><form id='rHrs7'><ins id='rHrs7'></ins><ul id='rHrs7'></ul><sub id='rHrs7'></sub></form><legend id='rHrs7'></legend><bdo id='rHrs7'><pre id='rHrs7'><center id='rHrs7'></center></pre></bdo></b><th id='rHrs7'></th></span></q></dt></tr></i><div class="crnbxar" id='rHrs7'><tfoot id='rHrs7'></tfoot><dl id='rHrs7'><fieldset id='rHrs7'></fieldset></dl></div>
                本文介紹了如果在循環中使用 MySQLi 準備好的語句,我什么時候調用 bind_param ?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在嘗試學習如何在 MySQLi 中使用準備好的語句來插入數據.

                I am trying to learn how to use prepared statements with MySQLi to insert data.

                盡管準備好的語句因其高效重復執行類似語句的能力而受到稱贊,但我似乎無法找到使用 MySQLi 在循環中執行多個語句的示例.我特別對以下內容感到困惑:

                Even though prepared statements are lauded for their ability to efficiently execute similar statements repeatedly, I can't seem to find examples of executing multiple statements in a loop using MySQLi. I'm especially confused about the following:

                • 是在我的循環之前還是在我的循環內調用bind_param
                • 是在調用 bind_param 之前還是之后為我的變量賦值
                • whether to call bind_param before my loop or inside my loop
                • whether to assign values to my variables before or after the call to bind_param

                大多數關于預處理語句的教程都使用 PDO.使用 PDO,可以將一組參數值傳遞給 execute,從而無需調用 bindParam.MySQLi 不是這種情況.

                Most tutorials on prepared statements use PDO. With PDO, an array of parameter values can be passed to execute, eliminating the need to call bindParam. This is not the case with MySQLi.

                PHP 手冊 mysqli_prepare 條目有一個示例,顯示了以下操作順序:

                The PHP manual mysqli_prepare entry has an example that shows the following order of operations:

                1. 為變量賦值
                2. 準備聲明
                3. 綁定變量
                4. 執行
                5. 關閉

                根據上述判斷,我假設我需要在循環中調用 bind 語句.

                Judging by the above, I had assumed that I would need to call the bind statement within my loop.

                然而,PHP 手冊 mysqli_stmt_execute 條目有一個顯示以下操作順序的示例:

                However, the PHP manual mysqli_stmt_execute entry has an example that shows the following order of operations:

                1. 準備聲明
                2. 綁定變量
                3. 為變量賦值
                4. 執行
                5. 為變量賦值
                6. 執行
                7. 關閉

                請注意,此示例未顯示的一件事是變量首次聲明的位置.我認為將未聲明的變量傳遞給 bind_param 會生成一個通知.我終于發現我可以傳遞未定義的變量,因為它們是通過引用傳遞的.

                Note that one thing this example doesn't show is where the variables are first declared. I thought passing undeclared variables to bind_param would generate a notice. I finally figured out that I can pass undefined variables because they are passed by reference.

                問題:
                一種操作順序是否優于另一種?還是僅僅取決于你在做什么?兩者之間有什么問題嗎?

                Question:
                Is one order of operations preferred over the other? Or does it just depend on what you are doing? Are there any gotchas with one or the other?

                注意:代碼已經使用 MySQLi,我不想切換到 PDO(現在切換不在本項目范圍內).

                Note: The code already uses MySQLi and I don't want to switch to PDO (switching now is outside the scope of this project).

                推薦答案

                因為參數是通過引用傳遞的,所以可以在之前給變量賦值> 在調用 bind_param 之后.無論哪種方式都行.

                Because the parameters are passed by reference, you can assign the values to the variables before or after the call to bind_param. Either way will work.

                如果變量是通過傳遞的,則每次更改它們的值時都需要綁定它們.但是因為它們是通過引用傳遞的,所以只需要綁定一次即可.

                If the variables were passed by value, you would need to bind them each time you changed their value. But since they are passed by reference, you only need to bind them once.

                在單次執行的情況下,操作順序并不重要,可能取決于值的來源.在循環的情況下,你一定要在循環之前調用bind_param.

                In the case of a single execute, the order of operation doesn't really matter and may depend on where the values are coming from. In the case of a loop, you should definitely call bind_param before the loop.

                這篇關于如果在循環中使用 MySQLi 準備好的語句,我什么時候調用 bind_param ?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 中保持其類型?)
                  • <bdo id='OIcm6'></bdo><ul id='OIcm6'></ul>
                  • <legend id='OIcm6'><style id='OIcm6'><dir id='OIcm6'><q id='OIcm6'></q></dir></style></legend>

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

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

                        <tfoot id='OIcm6'></tfoot>
                            <tbody id='OIcm6'></tbody>
                          主站蜘蛛池模板: 胶水,胶粘剂,AB胶,环氧胶,UV胶水,高温胶,快干胶,密封胶,结构胶,电子胶,厌氧胶,高温胶水,电子胶水-东莞聚力-聚厉胶粘 | 杭州代理记账多少钱-注册公司代办-公司注销流程及费用-杭州福道财务管理咨询有限公司 | 气弹簧定制-气动杆-可控气弹簧-不锈钢阻尼器-工业气弹簧-可调节气弹簧厂家-常州巨腾气弹簧供应商 | 非标压力容器_碳钢储罐_不锈钢_搪玻璃反应釜厂家-山东首丰智能环保装备有限公司 | 土壤养分检测仪|土壤水分|土壤紧实度测定仪|土壤墒情监测系统-土壤仪器网 | 专业甜品培训学校_广东糖水培训_奶茶培训_特色小吃培训_广州烘趣甜品培训机构 | 重庆LED显示屏_显示屏安装公司_重庆LED显示屏批发-彩光科技公司 重庆钣金加工厂家首页-专业定做监控电视墙_操作台 | 机床主轴维修|刀塔维修|C轴维修-常州翔高精密机械有限公司 | 手术室净化厂家_成都实验室装修公司_无尘车间施工单位_洁净室工程建设团队-四川华锐16年行业经验 | 自动气象站_气象站监测设备_全自动气象站设备_雨量监测站-山东风途物联网 | 江西自考网| 防火门-专业生产甲级不锈钢钢质防火门厂家资质齐全-广东恒磊安防设备有限公司 | 高温链条油|高温润滑脂|轴承润滑脂|机器人保养用油|干膜润滑剂-东莞卓越化学 | 船用泵,船用离心泵,船用喷射泵,泰州隆华船舶设备有限公司 | 护栏打桩机-打桩机厂家-恒新重工| 防渗土工膜|污水处理防渗膜|垃圾填埋场防渗膜-泰安佳路通工程材料有限公司 | 广州各区危化证办理_危险化学品经营许可证代办 | 东莞工作服_东莞工作服定制_工衣订做_东莞厂服 | PSI渗透压仪,TPS酸度计,美国CHAI PCR仪,渗透压仪厂家_价格,微生物快速检测仪-华泰和合(北京)商贸有限公司 | 成都珞石机械 - 模温机、油温机、油加热器生产厂家 | 针焰试验仪,灼热丝试验仪,漏电起痕试验仪,水平垂直燃烧试验仪 - 苏州亚诺天下仪器有限公司 | 衬四氟_衬氟储罐_四氟储罐-无锡市氟瑞特防腐科技有限公司 | 茶楼装修设计_茶馆室内设计效果图_云臻轩茶楼装饰公司 | 等离子空气净化器_医用空气消毒机_空气净化消毒机_中央家用新风系统厂家_利安达官网 | 智能终端_RTU_dcm_北斗星空自动化科技 | 耐磨焊丝,堆焊焊丝,耐磨药芯焊丝,碳化钨焊丝-北京耐默公司 | 湖南档案密集架,智能,物证,移动,价格-湖南档案密集架厂家 | app开发|app开发公司|小程序开发|物联网开发||北京网站制作|--前潮网络 | 代理记账_公司起名核名_公司注册_工商注册-睿婕实业有限公司 | 数字展示在线_数字展示行业门户网站 | ★济南领跃标识制作公司★济南标识制作,标牌制作,山东标识制作,济南标牌厂 | 江苏远邦专注皮带秤,高精度皮带秤,电子皮带秤研发生产 | 海德莱电力(HYDELEY)-无功补偿元器件生产厂家-二十年专业从事电力电容器 | 哈希余氯测定仪,分光光度计,ph在线监测仪,浊度测定仪,试剂-上海京灿精密机械有限公司 | 三佳互联一站式网站建设服务|网站开发|网站设计|网站搭建服务商 赛默飞Thermo veritiproPCR仪|ProFlex3 x 32PCR系统|Countess3细胞计数仪|371|3111二氧化碳培养箱|Mirco17R|Mirco21R离心机|仟诺生物 | 长江船运_国内海运_内贸船运_大件海运|运输_船舶运输价格_钢材船运_内河运输_风电甲板船_游艇运输_航运货代电话_上海交航船运 | 篮球架_乒乓球台_足球门_校园_竞技体育器材_厂家_价格-沧州浩然体育器材有限公司 | 并离网逆变器_高频UPS电源定制_户用储能光伏逆变器厂家-深圳市索克新能源 | 江苏全风,高压风机,全风环保风机,全风环形高压风机,防爆高压风机厂家-江苏全风环保科技有限公司(官网) | 学考网学历中心| 武汉天安盾电子设备有限公司 - 安盾安检,武汉安检门,武汉安检机,武汉金属探测器,武汉测温安检门,武汉X光行李安检机,武汉防爆罐,武汉车底安全检查,武汉液体探测仪,武汉安检防爆设备 |