Re: About DB class.
| From: | Stig S. Bakken | Date: | Mon, 11 Feb 2002 06:06:22 +0000 |
| Subject: | Re: About DB class. | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-4579@lists.php.net to get a copy of this message | ||
On Sun, 2002-02-10 at 14:49, Tomas V.V.Cox wrote:
> "Stig S. Bakken" wrote:
> >
> > On Mon, 2002-02-04 at 18:27, Vitaly N. Kravchenko wrote:
> > > Hi people!
> > >
> > > I have idea, about adding some function(methods) to DB class..
> > > __sleep() and __wakeup(), for storing DB objects in sessions..
> > > Is it possible?
> > > Cox?
> > >
> > > P.S. Have one question: if I have object with property = other object,
> > > for example:
> > > $myobj = new MyObj();
> > > but $myobj->$db = new DB(...);
> > >
> > > if I have __wakeup() methods in both classes, wich function
> > > are executed first? __wakeup() in DB ($myobj->db)
> > > or in MyObj ($myobj)?
> > >
> > > Thanks!
> >
> > Serializing the connection objects should be trivial, just call
> > $this->connect($this->dsn) from __wakeup().
> >
>
> I wonder if we could make a "connection on-demand" feature. So people
> could create the object in the typical "default.php" but don't spend
> system resources until they need them.
With the overload extension, that would be trivial. If you define a
method called __get_connection() in DB_common, it can just run
connect($this->dsn) and return $this->connection. Great idea :-)
- Stig
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc