Re: Re: mdb2: how to save a connection in a session
| From: | Daniel O'Connor | Date: | Thu, 19 Feb 2009 23:48:50 +0000 |
| Subject: | Re: Re: mdb2: how to save a connection in a session | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-29716@lists.php.net to get a copy of this message | ||
On Thu, Feb 19, 2009 at 8:13 PM, Paolo Sala <piviul@riminilug.it> wrote:
> Daniel O'Connor scrisse in data 19/02/2009 06:46:
> > http://au.php.net/manual/en/language.oop.magic-functions.phpô�$ƒëŒ
> > (í’‹àÐåB@
> Do you mean that in mdb2 __sleep and __wakeup are not implemented yet?
> If __sleep and __wakeup are implemented do you think the first query
> time's execution will be quicker?
>
I'd say don't worry about performance so much. Shift your connection to near
the very start of your application; then inject the database connection to
objects that need it.
// MyApplication.php
// 1. Connect to database
$db = MDB2::connect(...);
// 2. Pass the DB connection to all of the objects that need it
$foo->setDB($db);
$_SESSION['foo']->setDB($db);
Related info:
http://pooteeweet.org/blog/452