Re: [PHP] MySQL close connection, what's the purpose?

2006-04-03 Thread tedd
chris said: Time. Opening a db connection is time consuming. There are many levels involved (making the connection, authentication, etc).. Even worse if the connection is over tcp/ip because that overhead comes in on top as well. I replied: Have you timed it? Maybe I'll do that tomorrow.

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-03 Thread chris smith
On 4/3/06, tedd [EMAIL PROTECTED] wrote: chris said: Time. Opening a db connection is time consuming. There are many levels involved (making the connection, authentication, etc).. Even worse if the connection is over tcp/ip because that overhead comes in on top as well. I replied: Have

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-03 Thread tedd
chris said: Just out of interest, could you re-run the test using persistent connections? change mysql_connect to mysql_pconnect.. In doing so, the overall results dropped from a tenth of a second difference between both methods to three-one-hundredths of a second difference. In other

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-03 Thread Richard Lynch
On Mon, April 3, 2006 1:33 pm, tedd wrote: Just out of interest, could you re-run the test using persistent connections? change mysql_connect to mysql_pconnect.. In doing so, the overall results dropped from a tenth of a second difference between both methods to three-one-hundredths of a

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-03 Thread Jasper Bryant-Greene
tedd wrote: chris said: Just out of interest, could you re-run the test using persistent connections? change mysql_connect to mysql_pconnect.. [snip] Thanks -- does the persistent connection thing hold the server up until released? How does that work? MySQL is threaded so will not be

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread tedd
I always close the connection right after my query -- force of habit. It's like leaving the toilet seat up, it's only going to get you into trouble. So you close it after every query and then re-open it later for the next query? I don't see that as a good idea. No, you

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread Jasper Bryant-Greene
tedd wrote: I always close the connection right after my query -- force of habit. It's like leaving the toilet seat up, it's only going to get you into trouble. So you close it after every query and then re-open it later for the next query? I don't see that as a good idea.

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread chris smith
On 4/2/06, tedd [EMAIL PROTECTED] wrote: I always close the connection right after my query -- force of habit. It's like leaving the toilet seat up, it's only going to get you into trouble. So you close it after every query and then re-open it later for the next

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread tedd
At 11:07 AM +1200 4/2/06, Jasper Bryant-Greene wrote: tedd wrote: I always close the connection right after my query -- force of habit. It's like leaving the toilet seat up, it's only going to get you into trouble. So you close it after every query and then re-open it later

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread tedd
Time. Opening a db connection is time consuming. There are many levels involved (making the connection, authentication, etc).. Even worse if the connection is over tcp/ip because that overhead comes in on top as well. Have you timed it? It would be interesting to actually run a script that

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread Robert Cummings
On Sat, 2006-04-01 at 20:15, tedd wrote: Time. Opening a db connection is time consuming. There are many levels involved (making the connection, authentication, etc).. Even worse if the connection is over tcp/ip because that overhead comes in on top as well. Have you timed it? It would

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread Jasper Bryant-Greene
Robert Cummings wrote: On Sat, 2006-04-01 at 20:15, tedd wrote: It would be interesting to actually run a script that opens, retrieves, and inserts data -- let's say 50k times. What's the time difference between one open, 50k retrieves/inserts, and one close-- as compared 50k opens

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread Robert Cummings
On Sat, 2006-04-01 at 20:48, Jasper Bryant-Greene wrote: Yeah, e.g. I have a database objects layer that means I only write SQL in classes, everything else is just calling object methods. I create the database object at the start of every script but that doesn't necessarily open the

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread Jasper Bryant-Greene
Robert Cummings wrote: On Sat, 2006-04-01 at 20:48, Jasper Bryant-Greene wrote: Yeah, e.g. I have a database objects layer that means I only write SQL in classes, everything else is just calling object methods. I create the database object at the start of every script but that doesn't

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread Robert Cummings
On Sat, 2006-04-01 at 21:39, Jasper Bryant-Greene wrote: Robert Cummings wrote: There's smart lazy programming, and sloppy lazy programming. I don't trust anything magical in PHP. Most of us are familiar with the magic quotes and global vars fiascos *LOL*. But hey, if you can squeeze a

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread Jasper Bryant-Greene
Robert Cummings wrote: On Sat, 2006-04-01 at 21:39, Jasper Bryant-Greene wrote: Robert Cummings wrote: There's smart lazy programming, and sloppy lazy programming. I don't trust anything magical in PHP. Most of us are familiar with the magic quotes and global vars fiascos *LOL*. But hey, if

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread Robert Cummings
On Sat, 2006-04-01 at 21:57, Jasper Bryant-Greene wrote: Robert Cummings wrote: Of course, it wouldn't exactly be a rewrite to make it close the connection at the end of every script before PHP did, if I'm proven wrong and it one day is necessary. I'd only need to change the database

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread John Nichel
Jasper Bryant-Greene wrote: snip I never close connections; PHP does that for me and has never caused any problems doing that. I don't see it as sloppy programming, it is a documented feature that PHP closes resources such as database connections at the end of the script. It's extremely

Re: [PHP] MySQL close connection, what's the purpose?

2006-04-01 Thread Jasper Bryant-Greene
John Nichel wrote: Jasper Bryant-Greene wrote: snip I never close connections; PHP does that for me and has never caused any problems doing that. I don't see it as sloppy programming, it is a documented feature that PHP closes resources such as database connections at the end of the script.

Re: [PHP] MySQL close connection, what's the purpose?

2006-03-31 Thread Richard Lynch
On Fri, March 31, 2006 2:30 pm, Martin Zvarík wrote: I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? Yes, but... Suppose you write a script to read data from one MySQL server, and then insert it into

Re: [PHP] MySQL close connection, what's the purpose?

2006-03-31 Thread Martin Zvarík
Richard Lynch wrote: On Fri, March 31, 2006 2:30 pm, Martin Zvarík wrote: I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? Yes, but... Suppose you write a script to read data from one MySQL

Re: [PHP] MySQL close connection, what's the purpose?

2006-03-31 Thread Anthony Ettinger
On 3/31/06, Martin Zvarík [EMAIL PROTECTED] wrote: Richard Lynch wrote: On Fri, March 31, 2006 2:30 pm, Martin Zvarík wrote: I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? Yes, but...

Re: [PHP] MySQL close connection, what's the purpose?

2006-03-31 Thread tedd
At 10:30 PM +0200 3/31/06, Martin Zvarík wrote: Hi, I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? MZ MZ: I always close the connection right after my query -- force of habit. It's like leaving the

Re: [PHP] MySQL close connection, what's the purpose?

2006-03-31 Thread chris smith
On 4/1/06, tedd [EMAIL PROTECTED] wrote: At 10:30 PM +0200 3/31/06, Martin Zvarík wrote: Hi, I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? MZ MZ: I always close the connection right after my

Re: [PHP] MySQL close connection, what's the purpose?

2006-03-31 Thread Anthony Ettinger
On 3/31/06, chris smith [EMAIL PROTECTED] wrote: On 4/1/06, tedd [EMAIL PROTECTED] wrote: At 10:30 PM +0200 3/31/06, Martin Zvarík wrote: Hi, I was wondering why is it necessary to use mysql_close() at the end of your script. If you don't do it, it works anyways, doesn't it? MZ

Re: [PHP] MySQL close connection, what's the purpose?

2006-03-31 Thread chris smith
On 4/1/06, Anthony Ettinger [EMAIL PROTECTED] wrote: On 3/31/06, chris smith [EMAIL PROTECTED] wrote: On 4/1/06, tedd [EMAIL PROTECTED] wrote: At 10:30 PM +0200 3/31/06, Martin Zvarík wrote: Hi, I was wondering why is it necessary to use mysql_close() at the end of your script.