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

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

  • <tfoot id='t3vjq'></tfoot>
    1. <legend id='t3vjq'><style id='t3vjq'><dir id='t3vjq'><q id='t3vjq'></q></dir></style></legend>

      1. $stmt->close() vs $stmt->free_result()

        时间:2023-09-24
      2. <legend id='jk8eG'><style id='jk8eG'><dir id='jk8eG'><q id='jk8eG'></q></dir></style></legend><tfoot id='jk8eG'></tfoot>

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

                    <tbody id='jk8eG'></tbody>
                  本文介绍了$stmt->close() vs $stmt->free_result()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在完成准备好的 mysqli 时,我试图澄清 $stmt->close()$stmt->free_result() 之间的区别强>声明.

                  I am trying to clarify the difference between $stmt->close() and $stmt->free_result() when finalizing a prepared mysqli statement.

                  到目前为止我使用:

                  $mysqli = new mysqli(host,user,password,database);
                  $stmt = $mysqli->prepare(sql statement);
                  [...]
                  $stmt->free_result();
                  $mysqli->close();
                  

                  一切似乎都正常.

                  但我见过很多程序员使用 $stmt->close 而不是 $stmt->free_result().一旦我看到了他们两个:

                  But I've seen a lot of programmers use $stmt->close instead of $stmt->free_result(). And once I've seen both of them:

                  $stmt->free_result();
                  $stmt->close();
                  $mysqli->close();
                  

                  那么我应该选择什么,在什么情况下以及为什么?

                  So what should I choose, under which circumstances and why?

                  推荐答案

                  $stmt->free_result() 释放与结果集相关的内存,而 $stmt->close() 释放与准备好的语句相关的内存.随后调用 $stmt->close() 将取消任何剩余的结果.

                  $stmt->free_result() frees up memory related to a result set, whereas $stmt->close() frees up memory related to a prepared statement. Subsequently calling $stmt->close() will cancel any result still remaining.

                  本质上,调用 $stmt->close() 将提供与调用 $stmt->free_result() 相同的效果,因为它取消了结果集以及.但是调用 $stmt->free_result() 不会清除准备好的语句使用的内存,在这种情况下你必须使用 $stmt->close().

                  In essence, calling $stmt->close() will provide the same effect as calling $stmt->free_result() since it cancels the result set as well. But calling $stmt->free_result() will not clear out the memory used by the prepared statement in which case you must use $stmt->close().

                  至于使用哪个 - 可能在某些情况下,您打算使用已初始化的准备好的语句,但不再需要您当前拥有的结果集.在这种情况下,您将等待调用 $stmt->close() 直到完成准备好的语句,然后调用 $stmt->free_result()在执行另一个语句之前.

                  As far as which one to use goes - there may be situations where you intend on using the prepared statement you have initialized, but are no longer in need of the result set you currently have. In such a case you would wait on calling $stmt->close() until you are done with the prepared statement and instead call $stmt->free_result() before executing another statement.

                  这篇关于$stmt->close() vs $stmt->free_result()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:通过php将html表单数据发送到sql数据库(使用mysql 下一篇:使用 mysql 池对 node.js(集群)的性能进行基准测试

                  相关文章

                  最新文章

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

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