When I run a script (especially a billing script we use to bill billable phone calls, which uses the phone system database and the CRM to determine who called, if it was billable, if they have an account, etc...), which takes a few minutes I have time to run:
I get something like this:
You can see the connection count is 74. For now, let's say that's OK even though it seems high to me. There are other things going on in this server other than what I am just looking at (the phone system accesses it among other things).
Immediately after restarting the server my connection count is 72.
I run the script, and it jumps to 74.
When the script completes, I expect it to drop back down to 72.
It doesn't. Am I misreading this? Is this the historical connection count instead of the current / active connection count?
I'm definitely closing the database connections in PHP when I am done with them:
At the top of a page, I instantiate one instance of MySQLi for everything in that page to use. All functions, classes, etc... use dependency injection to utilize the same database connection, which originates at the very top of the script:
<?php$db = gimmieDB(); //Returns a MySQLi object connected to the databaseinclude('includes/application_top.php');//do other stuff.
You need to see what your gimmieDB returns.
The same way you have gimmieDB you need one that you release the connection.
You might be looking at the wrong part I.e. You may have a different code that opens he connection and never closes it.