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

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

    <legend id='ThK5a'><style id='ThK5a'><dir id='ThK5a'><q id='ThK5a'></q></dir></style></legend>

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

    1. <i id='ThK5a'><tr id='ThK5a'><dt id='ThK5a'><q id='ThK5a'><span id='ThK5a'><b id='ThK5a'><form id='ThK5a'><ins id='ThK5a'></ins><ul id='ThK5a'></ul><sub id='ThK5a'></sub></form><legend id='ThK5a'></legend><bdo id='ThK5a'><pre id='ThK5a'><center id='ThK5a'></center></pre></bdo></b><th id='ThK5a'></th></span></q></dt></tr></i><div class="s3iesct" id='ThK5a'><tfoot id='ThK5a'></tfoot><dl id='ThK5a'><fieldset id='ThK5a'></fieldset></dl></div>
    2. <tfoot id='ThK5a'></tfoot>
    3. 為什么我不能運行兩個 mysqli 查詢?第二個失敗

      Why can#39;t I run two mysqli queries? The second one fails(為什么我不能運行兩個 mysqli 查詢?第二個失敗)
        <tfoot id='xJ7U7'></tfoot>
      1. <legend id='xJ7U7'><style id='xJ7U7'><dir id='xJ7U7'><q id='xJ7U7'></q></dir></style></legend>

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

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

              1. 本文介紹了為什么我不能運行兩個 mysqli 查詢?第二個失敗的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                是否可以像這樣有兩個 mysqli 查詢?

                Is it possible to have two mysqli queries like so?

                mysqli_query($dblink, "INSERT INTO images (project_id, user_id, image_name, date_created, link_to_file, link_to_thumbnail, given_name) VALUES ('$project_id', '$user_id', '$image_name', '$date_created', '$link_to_file', '$thumbnail', '$ImageName')");
                mysqli_query($dblink, "INSERT INTO images_history (project_id, user_id, image_name, date_created, link_to_file, link_to_thumbnail, given_name, day, month, year) VALUES ('$project_id', '$user_id', '$image_name', '$date_created', '$link_to_file', '$thumbnail', '$ImageName', '$day', '$month', '$year')");
                

                基本上我想更新我的數據庫中的兩個表.有沒有更好的方法來做到這一點?

                Basically I want to update two tables in my DB. Is there a better way to do this?

                推薦答案

                mysqli_multi_query() 可以實現.

                示例:

                <?php
                
                $mysqli = new mysqli($host, $user, $password, $database);
                
                // create string of queries separated by ;
                $query  = "INSERT INTO images (project_id, user_id, image_name, date_created, link_to_file, link_to_thumbnail, given_name) VALUES ('$project_id', '$user_id', '$image_name', '$date_created', '$link_to_file', '$thumbnail', '$ImageName');";
                $query .= "INSERT INTO images_history (project_id, user_id, image_name, date_created, link_to_file, link_to_thumbnail, given_name, day, month, year) VALUES ('$project_id', '$user_id', '$image_name', '$date_created', '$link_to_file', '$thumbnail', '$ImageName', '$day', '$month', '$year');";
                
                // execute query - $result is false if the first query failed
                $result = mysqli_multi_query($mysqli, $query);
                
                if ($result) {
                    do {
                        // grab the result of the next query
                        if (($result = mysqli_store_result($mysqli)) === false && mysqli_error($mysqli) != '') {
                            echo "Query failed: " . mysqli_error($mysqli);
                        }
                    } while (mysqli_more_results($mysqli) && mysqli_next_result($mysqli)); // while there are more results
                } else {
                    echo "First query failed..." . mysqli_error($mysqli);
                }
                

                關鍵是,如果您想在一次調用中執行多個查詢,必須使用 mysqli_multi_query.出于安全原因,mysqli_query 不會執行多個查詢以防止 SQL 注入.

                The key is that you must use mysqli_multi_query if you want to execute more than one query in a single call. For security reasons, mysqli_query will not execute multiple queries to prevent SQL injections.

                還要記住 mysqli_store_result 的行為.如果查詢沒有結果集(INSERT 查詢沒有),它返回 FALSE 所以你還必須檢查 mysqli_error 以查看它返回一個空字符串表示 INSERT 成功.

                Also keep in mind the behavior of mysqli_store_result. It returns FALSE if the query has no result set (which INSERT queries do not) so you must also check mysqli_error to see that it returns an empty string meaning the INSERT was successful.

                見:
                mysqli_multi_query
                mysqli_more_results
                mysqli_next_result
                mysqli_store_result

                這篇關于為什么我不能運行兩個 mysqli 查詢?第二個失敗的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 中保持其類型?)
              2. <small id='hsauU'></small><noframes id='hsauU'>

                  <legend id='hsauU'><style id='hsauU'><dir id='hsauU'><q id='hsauU'></q></dir></style></legend>

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

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

                          主站蜘蛛池模板: 水冷散热器_水冷电子散热器_大功率散热器_水冷板散热器厂家-河源市恒光辉散热器有限公司 | 武汉EPS线条_EPS装饰线条_EPS构件_湖北博欧EPS线条厂家 | 数字展示在线_数字展示行业门户网站 | 尚为传动-专业高精密蜗轮蜗杆,双导程蜗轮蜗杆,蜗轮蜗杆减速机,蜗杆减速机生产厂家 | 东莞市天进机械有限公司-钉箱机-粘箱机-糊箱机-打钉机认准东莞天进机械-厂家直供更放心! | 电采暖锅炉_超低温空气源热泵_空气源热水器-鑫鲁禹电锅炉空气能热泵厂家 | 橡胶接头|可曲挠橡胶接头|橡胶软接头安装使用教程-上海松夏官方网站 | 大白菜官网,大白菜winpe,大白菜U盘装系统, u盘启动盘制作工具 | 高压直流电源_特种变压器_变压器铁芯-希恩变压器定制厂家 | 东莞市超赞电子科技有限公司 全系列直插/贴片铝电解电容,电解电容,电容器 | 400电话_400电话申请_888元包年_400电话办理服务中心_400VIP网 | 专业深孔加工_东莞深孔钻加工_东莞深孔钻_东莞深孔加工_模具深孔钻加工厂-东莞市超耀实业有限公司 | 塑料脸盆批发,塑料盆生产厂家,临沂塑料广告盆,临沂家用塑料盆-临沂市永顺塑业 | 微型气象仪_气象传感器_防爆气象传感器-天合传感器大全 | 无机纤维喷涂棉-喷涂棉施工工程-山东华泉建筑工程有限公司▲ | 上海办公室装修,办公楼装修设计,办公空间设计,企业展厅设计_写艺装饰公司 | 乐泰胶水_loctite_乐泰胶_汉高乐泰授权(中国)总代理-鑫华良供应链 | U拓留学雅思一站式服务中心_留学申请_雅思托福培训 | 高空重型升降平台_高空液压举升平台_高空作业平台_移动式升降机-河南华鹰机械设备有限公司 | 截齿|煤截齿|采煤机截齿|掘进机截齿|旋挖截齿-山东卓力截齿厂家报价 | 板框压滤机-隔膜压滤机配件生产厂家-陕西华星佳洋装备制造有限公司 | 钢结构-钢结构厂房-钢结构工程[江苏海逵钢构厂] | 曙光腾达官网-天津脚手架租赁-木板架出租-移动门式脚手架租赁「免费搭设」 | 玖容气动液压设备有限公司-气液增压缸_压力机_增压机_铆接机_增压器 | 宿舍管理系统_智慧园区系统_房屋/房产管理系统_公寓管理系统 | 南京试剂|化学试剂|分析试剂|实验试剂|cas号查询-专业60年试剂销售企业 | 等离子空气净化器_医用空气消毒机_空气净化消毒机_中央家用新风系统厂家_利安达官网 | 圆盘鞋底注塑机_连帮鞋底成型注塑机-温州天钢机械有限公司 | 合肥仿石砖_合肥pc砖厂家_合肥PC仿石砖_安徽旭坤建材有限公司 | FAG轴承,苏州FAG轴承,德国FAG轴承-恩梯必传动设备(苏州)有限公司 | 真石漆,山东真石漆,真石漆厂家,真石漆价格-山东新佳涂料有限公司 | 喷码机,激光喷码打码机,鸡蛋打码机,手持打码机,自动喷码机,一物一码防伪溯源-恒欣瑞达有限公司 | 千淘酒店差旅平台-中国第一家针对TMC行业的酒店资源供应平台 | 儿童语言障碍训练-武汉优佳加感统文化发展有限公司 | 电动高尔夫球车|电动观光车|电动巡逻车|电动越野车厂家-绿友机械集团股份有限公司 | 12cr1mov无缝钢管切割-15crmog无缝钢管切割-40cr无缝钢管切割-42crmo无缝钢管切割-Q345B无缝钢管切割-45#无缝钢管切割 - 聊城宽达钢管有限公司 | 无线联网门锁|校园联网门锁|学校智能门锁|公租房智能门锁|保障房管理系统-KEENZY中科易安 | 瑞典Blueair空气净化器租赁服务中心-专注新装修办公室除醛去异味服务! | 欧景装饰设计工程有限公司-无锡欧景装饰官网 | 【铜排折弯机,钢丝折弯成型机,汽车发泡钢丝折弯机,线材折弯机厂家,线材成型机,铁线折弯机】贝朗折弯机厂家_东莞市贝朗自动化设备有限公司 | 户外-组合-幼儿园-不锈钢-儿童-滑滑梯-床-玩具-淘气堡-厂家-价格 |