Close PDO connection
P粉041758700
P粉041758700 2023-10-14 19:05:33
0
1
657

This is just a fairly simple question about PDO compared to MySQLi.

Using MySQLi, to close the connection you can do the following:

$this->connection->close();

However, when using PDO, it states that you open the connection using:

$this->connection = new PDO();

But to close the connection, set it to null.

$this->connection = null;

Is this correct? Will this actually release the PDO connection? (I know it is like this because it is set to null.) What I mean is, with MySQLi, you have to call a function (close) to close the connection. Does PDO disconnect as easily as = null? Or is there a function to close the connection?

P粉041758700
P粉041758700

reply all(1)
P粉448346289

You are correct according to the documentation (http://php.net/manual/en/pdo.connections .php):

Please note that if a PDO object is initialized as a persistent connection, it will not automatically close the connection.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!