|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-07-05 19:39 UTC] cyberlot at cyberlot dot net
Description:
------------
mysqli, using class interface not not closing connection at end of script unless you specificly call $mysqli->close
This is a change of behavior from the normal mysql extension which does not "require" you to close connection.
Reproduce code:
---------------
<?
$mysqli = new extend_mysqli('localhost','billing','billing','billing');
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
?>
Expected result:
----------------
Every time its run it should release the database connection
Actual result:
--------------
Each time you run it a new db connection is done until you max out the mysql server.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
narrowed the problem down further, Its directly related to me trying to extend the mysqli class. If I take out the extend it closes properly, If I put in the extend with no functions at all it does not close properly So <? $mysqli = new extend_mysqli('localhost','billing','billing','billing'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } ?> Connection does not close properly <? $mysqli = new mysqli('localhost','billing','billing','billing'); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } ?> Connection does close properly.No your analysis looks correct. Try the following patch: diff -u -p -d -r1.41 mysqli.c --- ext/mysqli/mysqli.c 23 Jun 2004 16:47:25 -0000 1.41 +++ ext/mysqli/mysqli.c 5 Jul 2004 18:48:51 -0000 @@ -132,7 +132,7 @@ static void mysqli_objects_free_storage( FREE_HASHTABLE(intern->zo.properties); /* link object */ - if (intern->zo.ce == mysqli_link_class_entry) { + if (instanceof_function(intern->zo.ce, mysqli_link_class_entry TSRMLS_CC)) { if (my_res && my_res->ptr) { MY_MYSQL *mysql = (MY_MYSQL *)my_res->ptr;