In my php script, When I am executing query on certain PDO mysql connection, on checking mysql logs, I am not able to see the connection getting closed.
Php Code:
?php
$db = new PDO('mysql:host=HOST;dbname=DB',USER,PASSWORD);
$db->exec("SHOW TABLES");
$db = null;
?>
Mysql logs:
180312 18:31:45 9048429 Connect USER@HOST on DB
9048429 Query SHOW TABLES
Though, when I remove query, I can see the mysql connection closed on the Mysql log.
php code:
?php
$db = new PDO('mysql:host=HOST;dbname=DB',USER,PASSWORD);
$db = null;
?>
Mysql log:
180312 18:33:54 9048515 Connect USER@HOST on DB
9048515 Quit
I have to close mysql connection explicitly on my script to prevent too many connections. How can I do the same?