Do SQL connections opened with PDO in PHP have to be closed -
When I open a MySQL connection in PHP in the underlying MySQL functions of PHP, I do the following:
When I open a connection with the PDO, it looks like: Do I explicitly close the connection such as I TIA Use On a successful connection from the database, an example of PDO class is returned to your script which is active for the lifetime of that PDO object. To turn off the connection, you must destroy the object by making sure its remaining references have been removed - you specify this with the variable with the variable that holds the object. If you do not explicitly do this, then PHP will automatically close the connection when your script is finished.
$ link = new PDO ("mysql: dbname = $ dbname; Host = $ server ", $ username, $ password); // Ready statement, execute the query
mysql_connect ()
and mysql_close ()
$ link = null
to detect PDOs , It can close the connection.
Comments
Post a Comment