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
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/my***********...ie.nctu.edu.tw