Just a rather simple question with regards to PDO compared to MySQLi.
With MySQLi, to close the connection you could do:
$this->connection->close();
However with PDO it states you open the connection using:
$this->connection = new PDO();
but to close the connection you set it to null
.
$this->connection = 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?
According to documentation you're correct (http://php.net/manual/en/pdo.connections.php):
Note that if you initialise the PDO object as a persistent connection it will not automatically close the connection.
I created a derived class to have a more self-documenting instruction instead of "$conn=null;".
So i can call my code between: