• <tfoot id='Gn2xb'></tfoot>
    1. <i id='Gn2xb'><tr id='Gn2xb'><dt id='Gn2xb'><q id='Gn2xb'><span id='Gn2xb'><b id='Gn2xb'><form id='Gn2xb'><ins id='Gn2xb'></ins><ul id='Gn2xb'></ul><sub id='Gn2xb'></sub></form><legend id='Gn2xb'></legend><bdo id='Gn2xb'><pre id='Gn2xb'><center id='Gn2xb'></center></pre></bdo></b><th id='Gn2xb'></th></span></q></dt></tr></i><div id='Gn2xb'><tfoot id='Gn2xb'></tfoot><dl id='Gn2xb'><fieldset id='Gn2xb'></fieldset></dl></div>
      <legend id='Gn2xb'><style id='Gn2xb'><dir id='Gn2xb'><q id='Gn2xb'></q></dir></style></legend>

      • <bdo id='Gn2xb'></bdo><ul id='Gn2xb'></ul>

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

        php 5.2.6 的 mysqli_stmt_get_result 替代方案

        时间:2023-07-30
            <tbody id='lVfvJ'></tbody>
        1. <legend id='lVfvJ'><style id='lVfvJ'><dir id='lVfvJ'><q id='lVfvJ'></q></dir></style></legend>

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

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

        2. <tfoot id='lVfvJ'></tfoot>
            <bdo id='lVfvJ'></bdo><ul id='lVfvJ'></ul>

                • 本文介绍了php 5.2.6 的 mysqli_stmt_get_result 替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我不是php专家,我开发了一个查询mysql数据库的小服务.

                  I am not an expert of php, I developed a small service which query a mysql db.

                  但是我用 php 5.4 开发,然后发现我的虚拟主机计划有 5.2.6,所以我对一些未定义的函数几乎没有问题.

                  However I developed with php 5.4, and then discovered that my web hosting plan has 5.2.6, so I am having few problems with some undefined function.

                  具体来说,在这种情况下,如何解决 > 5.3 上可用的 mysqli_stmt_get_result 未定义函数?代码如下:

                  Specifically, in this case, how can I solve the mysqli_stmt_get_result undefined function available on > 5.3 ? Here is the code:

                    $stmt = mysqli_prepare($con,$db_query);
                  
                    if($stmt) {
                  
                       mysqli_stmt_bind_param($stmt,'ss',$after,$lang);
                       mysqli_stmt_execute($stmt);
                       $result = mysqli_stmt_get_result($stmt); // <-- getting undefined error here !!!
                  
                       $updated = array();
                       $deleted = array();
                  
                       while($row = mysqli_fetch_assoc($result)) {
                  
                          if($row['status']==1) {
                             array_push($updated,$row);
                          } else {
                             $cardName=$row['cardName'];
                             $cardStatus=$row['status'];
                             $cardId=$row['cardId'];
                             $language=$row['language'];
                             array_push($deleted,array(
                                      'cardName'=>$cardName,
                                                      'status'=>$cardStatus,
                                                      'cardId'=>$cardId,
                                                      'language'=>$language
                                                 )
                             );
                          }
                       }
                  
                       $response = array(
                          'cards'=>array(
                             'updated'=>$updated,
                             'deleted'=>$deleted
                          )
                       );
                  
                       $json = json_encode($response);
                       mysqli_close($con);
                       echo $json;
                  
                    }
                  

                  关键是我使用的是准备好的语句,由于我缺乏 php 知识,我发现没有其他方法可以在不重写整个脚本的情况下解决问题.

                  The point is that I am using a prepared statement, due to my lack of php knowledge I found no other way of resolving the issue without rewriting the whole script.

                  我认为你们中的一些人可能有一个简单易行的解决方案.

                  I thought that some of you may have a simple and easy solution.

                  推荐答案

                  mysqli_stmt_get_result 函数仅适用于 PHP 5.3 或更高版本.您的 PHP 5.2.x 版本不存在它(顺便说一句,不再支持该版本).

                  The mysqli_stmt_get_result function is PHP 5.3 or greater only. It does not exist for your PHP 5.2.x version (which is not supported any longer btw.).

                  另一种方法是使用带有变量绑定的 mysqli_stmt_bind_result.

                  The alternative is to use mysqli_stmt_bind_result with variable bindings.

                  在您的具体示例中,这甚至具有您不需要将数组成员分配给变量的好处,因为您可以直接绑定变量.

                  In your concrete example this has even the benefit that you do not need to assign the array members to variables, because you can bind the variables directly.

                  引入mysqli_stmt_get_result 函数是因为有人认为 这会妨碍您并且获取数组会更容易.

                  The mysqli_stmt_get_result function was introduced because someone thought this would stand in your way and getting an array would have been easier.

                  这篇关于php 5.2.6 的 mysqli_stmt_get_result 替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在准备好的语句上使用 fetch_assoc (php mysqli) 下一篇:Mysqli 查询不能工作两次

                  相关文章

                  最新文章

                    <bdo id='0dQpm'></bdo><ul id='0dQpm'></ul>

                • <legend id='0dQpm'><style id='0dQpm'><dir id='0dQpm'><q id='0dQpm'></q></dir></style></legend>

                • <tfoot id='0dQpm'></tfoot>
                • <i id='0dQpm'><tr id='0dQpm'><dt id='0dQpm'><q id='0dQpm'><span id='0dQpm'><b id='0dQpm'><form id='0dQpm'><ins id='0dQpm'></ins><ul id='0dQpm'></ul><sub id='0dQpm'></sub></form><legend id='0dQpm'></legend><bdo id='0dQpm'><pre id='0dQpm'><center id='0dQpm'></center></pre></bdo></b><th id='0dQpm'></th></span></q></dt></tr></i><div id='0dQpm'><tfoot id='0dQpm'></tfoot><dl id='0dQpm'><fieldset id='0dQpm'></fieldset></dl></div>

                    <small id='0dQpm'></small><noframes id='0dQpm'>