By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,081 Members | 861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,081 IT Pros & Developers. It's quick & easy.

shouldn't mysql_pconnect force reuse of mysql connections?

P: n/a
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

Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.