note 22957 rejected from function.mysql-close by didou

From: Date: Sun, 05 Oct 2003 18:52:00 +0000
Subject: note 22957 rejected from function.mysql-close by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57857@lists.php.net to get a copy of this message
Note Submitter: derek@nospam.mapiq.com ---- By the looks of it Linux version of PHP doesnt close the connection at all. I tested a few different ways of trying to close the connection, but havent found anything thats really useful as of yet. Below is what I use for my connections: class database { var $host = "www.somesite.com"; var $user = "user"; var $pass = "p4ssw0rd"; var $d_base; var $conx; var $db; function connectdb ( $db_name="dbase" ) { $this->d_base = $db_name; $this->conx = mysql_connect ( $this->host, $this->user, $this->pass ) or sql_error ( "db-connect", mysql_error() ); $this->db = mysql_select_db ( $this->d_base, $this->conx ) or sql_error ( "db-select", mysql_error() ); } function closedb ( ) { mysql_close ( $this->conx ) or sql_error ( "db-close", mysql_error() ); } } Then by running a simple test, I do a query and close the connection after it is completed. $db = New database(); $db->connectdb (); $q[0] = "SELECT * FROM sometable WHERE id = '$an_id'"; $sql[0] = mysql_query ( $q[0] ) or sql_error ( "db-query", mysql_error() ); $res[0] = mysql_fetch_array ( $sql[0] ) or sql_error ( "db-fetch", mysql_error() ); $db->closedb (); Doing this gives me an error message of "No Database Selected" In the closedb() function I also tried doing this, to see if this resolved anything, but alas I could continue querying after these were executed. $this->conx = NULL; $this->db = NULL; and unset ( $this->conx ); unset ( $this->db ); Im not sure if this is intentional or it is an actual bug in PHP, but I wouldnt mind knowing what is the status with this feature.

« previous php.notes (#57857) next »