Re: MySQL close connection, what's the purpose?
| From: | Robert Cummings | Date: | Sun, 02 Apr 2006 02:29:26 +0000 |
| Subject: | Re: MySQL close connection, what's the purpose? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-233077@lists.php.net to get a copy of this message | ||
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 database connection. The database connection is
> opened when I make my first query.
>
> That way if a page does no queries (I use APC caching so it is fairly
> common for a page to do no queries) then no database connection is opened.
>
> 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.
>
> But, as has been said, each to their own.
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
rewrite of an application out of a client for relying on dirty
techniques, who am I to critique your forward thinking manipulative
methods -- not to say that's your intent -- but I'd sure question your
motives and judgement if it comes around ;)
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. |
`------------------------------------------------------------'