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?
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.