Re: Internal use of Mysql Connections

From: Date: Sat, 22 Sep 2001 03:03:58 +0000
Subject: Re: Internal use of Mysql Connections
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-68296@lists.php.net to get a copy of this message
If you need multiple connections, you should store them in variables and keep track of them. The "last connection" is a convenience for single-connection users. Opening a MySQL connection is quite slow, so you really don't want to do it more than you have to. -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: Bob Silva <bob@bravenet.com> Newsgroups: php.general To: <php-general@lists.php.net> Sent: Thursday, September 20, 2001 10:48 AM Subject: Internal use of Mysql Connections Just curious why mysql wouldnt restore the last known internal connection id. In the code below, I open a connection (without storing the connection id), use it, then open,use,close a different connection, this time using a connection id, but when I close it, the original internal connection id is history, the last query fails. It would make sense to me that php would restore the last known connection handle (if there is one) after I call mysql_close(); I know I could call mysql_connect again after the mysql_close call and that would restore it. Any ideas? Thanks, Bob mysql_connect("hostname", "user", "pass"); $res = mysql_db_query("mlm","select count(*) from mlm_clients"); echo mysql_num_rows($res)."<br>"; $conn = mysql_connect("hostname", "user", "pass"); $res = mysql_db_query("rollcall","select count(*) from rollcall_students"); echo mysql_num_rows($res)."<br>"; mysql_close($conn); FAILS --> $res = mysql_db_query("mlm","select count(*) from mlm_clients"); echo mysql_num_rows($res)."<br>";

« previous php.general (#68296) next »