473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

shouldn't mysql_pconnect force reuse of mysql connections?

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
0 1052

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Randell D. | last post by:
Folks, I currently connect to my db with PHP code that uses non-persistent connections. I've read that persistent connections can help performance since a connection to the db will use an...
4
by: Yun Guan | last post by:
Hello folks, In my php scripts, those mysql functions, like mysql_pconnect() and mysql_connect() are said to be undefined. What do I miss here? Thanks. -- Allen Guan 281-489-2314
0
by: anders thoresson | last post by:
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",...
4
by: OneSolution | last post by:
Coming from a java background, I've been taught that connection pooling is the best thing due to the obvious benefits. I found out that the above pconnect() function will pool connections. So...
4
by: Angelos | last post by:
I get this error mysql_pconnect Too many connections ... every now and then. Does anyone knows where it comes from ? There are a lot of sites running on the server and all of them use the...
1
by: WhatsPHP | last post by:
Can I use mysql_pconnect on an environment like this? There is just 1 server on which both PHP and MYSQL runs. It is an intranet server. At any point atleast 2 people will be actively using the...
11
by: =?ISO-8859-1?Q?J=F8rn?= Dahl-Stamnes | last post by:
Hello, I have been using mysql_connect in a script that display a lot of thumbnails for an album. Each thumbnail is displayed using the code: <IMG SRC="thm.php?id=some_id" ALT="some title"> ...
4
hsriat
by: hsriat | last post by:
Got an issue regarding this... As said above (same as what php.net says), if we use mysql_pconnect(), it doesn't create more connections, if the connection parameters are same as the existing...
9
by: John Murtari | last post by:
Folks, We have a fairly busy web site present using PHP 5 to talk to a MySQL 5.0.45 DB on an Apache 1.3 series server. It's spread out over several physical hosts (one DB server), we use DB...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.