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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 
> >> objects layer.
> > 
> > Wrong, you would just be doing the same thing PHP does... closing the
> > connection at the end of the script. What happens if you need to open 20
> > connections to 20 different databases... are you going to keep them all
> > open? I guess you would since it sounds like you don't have a facility
> > to close them. I don't think what you're doing is incredibly obscene, I
> > mean 90% of PHP developers are doing the same thing. 90% of the coding
> > population can't be wrong... but one that same line of thought... when
> > you open an image file or text file for reading or writing... do you
> > close it? Or just leave it open for PHP to close at the end? I mean PHP
> > will magically close all resources for you, there's obviously no need to
> > close it... or maybe there are valid times when you need to close a
> > resource yourself, I dunno, I feel like I'm out on a limb here ;)
> 
> Yeah, I can see your point. Simple answer though: my framework isn't 
> designed for connecting to 20 different databases :) It's designed for 
> normal database-driven websites -- where there usually a maximum of two 
> connections (master and slave), and often only one connection, open.

Now getting away from you particular framework and back to the original
question: "MySQL close connection, what's the purpose?", we now have an
answer :)

> I guess I'm just gambling the time-saving benefits of not having to call 
> $db->close() or whatever all the time, against the slim possibility that 
> I might one day have to write a new framework to deal with apps that do 
> 20+ DB connections at once. The framework is fairly light anyway as it's 
> built on top of PDO, so a rewrite is not a huge deal.

I agree with you in general that the likelihood of PHP stopping it's
support for auto closing of connections is highly unlikely, but this
question wasn't about your framework, but rather about automatic closing
of MySQL connections in general... and so, somebody out there probably
does have an environment where closing the connections makes a LOT of
sense.

BTW, who used register globals and magic quotes in the past and relied
on the argument that PHP would never get rid of them due to the number
of scripts that would break -- show of hands please! *grin*

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux