shouldn't mysql_pconnect force reuse of mysql connections?

From: Date: Tue, 19 Aug 2003 16:42:40 +0000
Subject: shouldn't mysql_pconnect force reuse of mysql connections?
Groups: php.general 
Request: Send a blank email to php-general+get-160020@lists.php.net to get a copy of this message
Hi, I have this function I call everytime I need to make a query from within my php-scripts: function db_connect ($user, $pwd, $db, $debug = 0) { $link = @mysql_pconnect("localhost", "$user", "$pwd"); if($link && mysql_select_db("$db")) if($debug == 1) { printf("Connection OK!"); } Return ($link); if($debug == 1) { printf("Connection not ok!"); } Return (FALSE); } I thought that making another or a third call to db_connect would reuse the same connection to the database, since I use mysql_pconnect() to connect. But listing the active processes indicates something else: +-------+-------+-----------+-------+---------+------+-------+-------------- ----+
| Id    | User  | Host      | db    | Command | Time | State | Info            |
+-------+-------+-----------+-------+---------+------+-------+-------------- ----+
| 64494 | thore | localhost | thore | Sleep   | 222  |       |                 |
| 64497 | thore | localhost | thore | Sleep   | 218  |       |                 |
| 64505 | thore | localhost | thore | Sleep   | 207  |       |                 |
| 64552 | thore | localhost | thore | Sleep   | 15   |       |                 |
| 64557 | thore | localhost | thore | Sleep   | 0    |       |                 |
| 64563 | thore | localhost | thore | Sleep   | 5    |       |                 |
| 64564 | thore | localhost |       | Query   | 0    |       | show processlist |
+-------+-------+-----------+-------+---------+------+-------+-------------- ----+
Have I misunderstood the process listing, the meaning of mysql_pconnect() or am I using mysql_pconnect() the wrong way when I call my function db_connect() before every query I make? -- anders thoresson

« previous php.general (#160020) next »