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

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

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

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

        <tfoot id='izudR'></tfoot>

        長文本字段上準備好的 mysqli 選擇語句返回空

        Prepared mysqli select statement on longtext field is coming back empty(長文本字段上準備好的 mysqli 選擇語句返回空)
          <tbody id='oKot4'></tbody>

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

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

          <tfoot id='oKot4'></tfoot>
              <legend id='oKot4'><style id='oKot4'><dir id='oKot4'><q id='oKot4'></q></dir></style></legend>
                  <bdo id='oKot4'></bdo><ul id='oKot4'></ul>
                  本文介紹了長文本字段上準備好的 mysqli 選擇語句返回空的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個運行良好的數據庫查詢功能——除了我遇到了顯然是 mysqli 準備好的語句和長文本字段的已知問題.發生的情況是,即使通過 phpMyAdmin 運行查詢工作正常,longtext 字段始終顯示為空.根據 http://www.workinginboxershorts.com/php-mysqli-returns-empty-variables-from-longtext-column,將數據類型切換為文本即可解決問題.但是,在我的情況下,我真的更愿意在我可以預見的時間里盡可能長地離開該字段,這些額外的空間將是有價值的.

                  I've got a database query function that works well -- except that I'm running into what's apparently a known issue with mysqli prepared statements and longtext fields. What happens is that the longtext field always comes up empty even though running the query through phpMyAdmin works fine. According to http://www.workinginboxershorts.com/php-mysqli-returns-empty-variables-from-longtext-column, switching the datatype to text solves the problem. However, in my case I'd really prefer to leave the field as longtext as I can foresee times when that extra space would be valuable.

                  我正在使用參數化查詢,這顯然是問題所在.這是我的功能:

                  I'm using parameterized queries, which evidently is the problem. Here's my function:

                  // Bind results to an array
                  // $stmt = sql query, $out = array to be returned
                  function stmt_bind_assoc (&$stmt, &$out) {
                    $data = mysqli_stmt_result_metadata($stmt);
                    $fields = array();
                    $out = array();
                  
                    $fields[0] = $stmt;
                    $count = 1;
                  
                    while($field = mysqli_fetch_field($data)) {
                      $fields[$count] = &$out[$field->name];
                      $count++;
                    }    
                  call_user_func_array('mysqli_stmt_bind_result', $fields);
                  }
                  
                  // DB Query
                  // $query = SQL query, $params = array of parameters, $rs = whether or not a resultset is expected, $newid = whether or not to retrieve the new ID value;
                  // $onedimensionkey = key required to convert array into simple one dimensional array
                  function db_query($query, $params, $rs = true, $newid = false, $onedimensionkey = false) {
                    $link = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
                    if (!$link) { 
                      print 'Error connecting to MySQL Server. Errorcode: ' . mysqli_connect_error(); 
                      exit; 
                    }
                  
                    // Prepare the query and split the parameters array into bound values
                    if ($sql_stmt = mysqli_prepare($link, $query)) {
                      if ($params) {
                        $types = '';
                        $new_params = array();
                        $params_ref = array();
                        // Split the params array into types string and parameters sub-array
                        foreach ($params as $param) {
                          $types .= $param['type'];
                          $new_params[] = $param['value'];
                        }
                        // Cycle the new parameters array to make it an array by reference
                        foreach ($new_params as $key => $parameter) {
                          $params_ref[] = &$new_params[$key];
                        }
                        call_user_func_array('mysqli_stmt_bind_param', array_merge(array($sql_stmt, $types), $params_ref));
                      }
                    }
                    else {
                      print 'Error: ' . mysqli_error($link);
                      exit();
                    }
                  
                    // Execute the query
                    mysqli_stmt_execute($sql_stmt);
                  
                    // If there are results to retrive, do so
                    if ($rs) {
                      $results = array();
                      $rows = array();
                      $row = array();
                      stmt_bind_assoc($sql_stmt, $results);
                      while (mysqli_stmt_fetch($sql_stmt)) {
                        foreach ($results as $key => $value) {
                          $row[$key] = $value;
                        }
                        $rows[] = $row;
                      }
                      if ($onedimensionkey) {
                        $i = 0;
                        foreach ($rows as $row) {
                          $simplearray[$i] = $row[$onedimensionkey];
                          $i++;
                        }
                        return $simplearray;
                      }
                      else {
                        return $rows;
                      }
                    }
                    // If there are no results but we need the new ID, return it
                    elseif ($newid) {
                      return mysqli_insert_id($link);
                    }
                  
                    // Close objects
                    mysqli_stmt_close($sql_stmt);
                    mysqli_close($link);
                  }
                  

                  根據我發布的鏈接,有一種解決方法涉及完成事情的順序,但要么我以與示例完全不同的方式處理我的查詢,要么我根本不了解重要的事情.

                  According to the link that I posted there is a workaround involving the order in which things are done, but either I'm handling my query in a completely different manner than the example or I'm simply not understanding something important.

                  感謝任何可以提供幫助的人!

                  Thanks to anyone who can help!

                  感謝 Corina 的回答,我已經解決了這個問題——對于遇到問題的其他人,您只需在 mysql_stmt_execute 命令之后添加以下內容:

                  Thanks to Corina's answer, I've solved this -- for anyone else who runs into the problem, you will simply need to add the following after the mysql_stmt_execute command:

                  // Execute the query
                  mysqli_stmt_execute($sql_stmt);
                  
                  // Store results
                  mysqli_stmt_store_result($sql_stmt);
                  

                  推薦答案

                  我通過調用 mysqli_stmt_store_result 在綁定數據之前.

                  I managed to solve the same issue by calling mysqli_stmt_store_result before binding the data.

                  有人遇到了同樣的問題并在 php.net 網站:

                  Someone had the same problem and shared the answer on the php.net website:

                  顯然,如果你有長文本,你必須打電話在使用 bind_result 之前 store_result.

                  Apparently, if you have longtext present, you HAVE to call store_result before using bind_result.

                  http://bugs.php.net/bug.php?id=47928

                  這篇關于長文本字段上準備好的 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 中保持其類型?)
                    <bdo id='avXSb'></bdo><ul id='avXSb'></ul>

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

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

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

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

                            主站蜘蛛池模板: 开平机_纵剪机厂家_开平机生产厂家|诚信互赢-泰安瑞烨精工机械制造有限公司 | 台式低速离心机-脱泡离心机-菌种摇床-常州市万丰仪器制造有限公司 | 组织研磨机-高通量组织研磨仪-实验室多样品组织研磨机-东方天净 传递窗_超净|洁净工作台_高效过滤器-传递窗厂家广州梓净公司 | 防锈油-助焊剂-光学玻璃清洗剂-贝塔防锈油生产厂家 | 污水/卧式/潜水/钻井/矿用/大型/小型/泥浆泵,价格,参数,型号,厂家 - 安平县鼎千泵业制造厂 | 赛默飞Thermo veritiproPCR仪|ProFlex3 x 32PCR系统|Countess3细胞计数仪|371|3111二氧化碳培养箱|Mirco17R|Mirco21R离心机|仟诺生物 | 播音主持培训-中影人教育播音主持学苑「官网」-中国艺考界的贵族学校 | 产业规划_产业园区规划-产业投资选址及规划招商托管一体化服务商-中机院产业园区规划网 | 赛默飞Thermo veritiproPCR仪|ProFlex3 x 32PCR系统|Countess3细胞计数仪|371|3111二氧化碳培养箱|Mirco17R|Mirco21R离心机|仟诺生物 | 风信子发稿-专注为企业提供全球新闻稿发布服务 | 法兰螺母 - 不锈钢螺母制造厂家 - 万千紧固件--螺母街 | elisa试剂盒价格-酶联免疫试剂盒-猪elisa试剂盒-上海恒远生物科技有限公司 | 精密模具制造,注塑加工,吹塑和吹瓶加工,EPS泡沫包装生产 - 济南兴田塑胶有限公司 | 雷冲击高压发生器-水内冷直流高压发生器-串联谐振分压器-武汉特高压电力科技有限公司 | 机械立体车库租赁_立体停车设备出租_智能停车场厂家_春华起重 | 抖音短视频运营_企业网站建设_网络推广_全网自媒体营销-东莞市凌天信息科技有限公司 | 最新范文网_实用的精品范文美文网| POS机办理_个人POS机免费领取 - 银联POS机申请首页 | 全自动在线分板机_铣刀式在线分板机_曲线分板机_PCB分板机-东莞市亿协自动化设备有限公司 | 苏州教学设备-化工教学设备-环境工程教学模型|同科教仪 | 披萨石_披萨盘_电器家电隔热绵加工定制_佛山市南海区西樵南方综合保温材料厂 | 高速龙门架厂家_监控杆_多功能灯杆_信号灯杆_锂电池太阳能路灯-鑫世源照明 | 骁龙云呼电销防封号系统-axb电销平台-外呼稳定『免费试用』 | 新疆乌鲁木齐网站建设-乌鲁木齐网站制作设计-新疆远璨网络 | 乐考网-银行从业_基金从业资格考试_初级/中级会计报名时间_中级经济师 | 酵素生产厂家_酵素OEM_酵素加盟_酵素ODM_酵素原料厂家_厦门益力康 | 软文发布平台 - 云软媒网络软文直编发布营销推广平台 | 集装箱展厅-住人集装箱住宿|建筑|房屋|集装箱售楼处-山东锐嘉科技工程有限公司 | 板材品牌-中国胶合板行业十大品牌-环保板材-上海声达板材 | 上海璟文空运首页_一级航空货运代理公司_机场快递当日达 | 合肥办公室装修 - 合肥工装公司 - 天思装饰 | 北京网站建设首页,做网站选【优站网】,专注北京网站建设,北京网站推广,天津网站建设,天津网站推广,小程序,手机APP的开发。 | 【德信自动化】点胶机_全自动点胶机_自动点胶机厂家_塑料热压机_自动螺丝机-深圳市德信自动化设备有限公司 | 超声波清洗机_大型超声波清洗机_工业超声波清洗设备-洁盟清洗设备 | 标准品网_标准品信息网_【中检计量】 | 电动卫生级调节阀,电动防爆球阀,电动软密封蝶阀,气动高压球阀,气动对夹蝶阀,气动V型调节球阀-上海川沪阀门有限公司 | 深圳装修_店面装修设计_餐厅设计_装修全包价格-尚泰装饰设计 | cnc精密加工_数控机械加工_非标平键定制生产厂家_扬州沃佳机械有限公司 | 全自动过滤器_反冲洗过滤器_自清洗过滤器_量子除垢环_量子环除垢_量子除垢 - 安士睿(北京)过滤设备有限公司 | 智能电表|预付费ic卡水电表|nb智能无线远传载波电表-福建百悦信息科技有限公司 | 低粘度纤维素|混凝土灌浆料|有机硅憎水粉|聚羧酸减水剂-南京斯泰宝 |