<small id='8HpGI'></small><noframes id='8HpGI'>

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

        <bdo id='8HpGI'></bdo><ul id='8HpGI'></ul>

      PDO 关闭连接

      时间:2023-09-21

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

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

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

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

                <tbody id='ICZqq'></tbody>
                <bdo id='ICZqq'></bdo><ul id='ICZqq'></ul>
                本文介绍了PDO 关闭连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                与 MySQLi 相比,PDO 只是一个相当简单的问题.

                Just a rather simple question with regards to PDO compared to MySQLi.

                使用 MySQLi,您可以关闭连接:

                With MySQLi, to close the connection you could do:

                $this->connection->close();
                

                但是对于 PDO,它声明您使用以下方式打开连接:

                However with PDO it states you open the connection using:

                $this->connection = new PDO();
                

                但要关闭连接,请将其设置为 null.

                but to close the connection you set it to null.

                $this->connection = null;
                

                这是否正确,这是否会真正释放 PDO 连接?(我知道它设置为 null.)我的意思是使用 MySQLi 你必须调用一个函数 (close) 来关闭连接.PDO 是否像 = null 一样容易断开连接?或者有没有关闭连接的功能?

                Is this correct and will this actually free the PDO connection? (I know it does as it is set to null.) I mean with MySQLi you have to call a function (close) to close the connection. Is PDO as easy as = null to disconnect? Or is there a function to close the connection?

                推荐答案

                根据文档,您是正确的 (http://php.net/manual/en/pdo.connections.php):

                According to documentation you're correct (http://php.net/manual/en/pdo.connections.php):

                连接在该 PDO 对象的生命周期内保持活动.到关闭连接,您需要通过确保销毁对象对它的所有剩余引用都将被删除——您可以通过分配NULL 到保存对象的变量.如果你不这样做明确地,PHP 会在您输入时自动关闭连接脚本结束.

                The connection remains active for the lifetime of that PDO object. To close the connection, you need to destroy the object by ensuring that all remaining references to it are deleted--you do this by assigning NULL to the variable that holds the object. If you don't do this explicitly, PHP will automatically close the connection when your script ends.

                请注意,如果您将 PDO 对象初始化为持久连接,它不会自动关闭连接.

                Note that if you initialise the PDO object as a persistent connection it will not automatically close the connection.

                这篇关于PDO 关闭连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:带有“WHERE ... IN"的 PDO查询 下一篇:PDO 的查询与执行

                相关文章

                最新文章

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

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

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