久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

        <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="qwawimqqmiuu" 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="qwawimqqmiuu" 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="qwawimqqmiuu" 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>
                          主站蜘蛛池模板: 日韩综合一区 | 精品av| 中文在线播放 | 久久久久www | 日本三级全黄三级a | 精品一区二区三区免费视频 | 亚洲最色视频 | 波多野结衣一二三区 | 一级看片免费视频囗交动图 | 久久久91精品国产一区二区三区 | 超碰日本 | 激情五月婷婷综合 | 69精品久久久久久 | 日韩精品一区中文字幕 | 欧美精品在欧美一区二区少妇 | 日韩在线视频免费观看 | 欧美一区免费 | 久久日韩粉嫩一区二区三区 | 成人三区四区 | 爱爱免费视频网站 | 久久综合九色综合欧美狠狠 | 国产精品久久久久久久久久久免费看 | 久久99精品久久久久久青青日本 | 日本高清不卡视频 | 日本精品一区二区 | 久久久久久久国产 | 国产精品黄视频 | 伊人看片 | 日韩视频在线免费观看 | 日日干夜夜干 | 日韩一区精品 | 久久久久久久久久久国产 | 午夜激情影院 | 玖玖国产| 中文字幕一区二区三区不卡 | 波多野结衣在线观看一区二区三区 | 欧美成人一区二免费视频软件 | 精品一区国产 | av免费网址 | 久久久久久高潮国产精品视 | 国产h在线 |