Re: About DB class.
| From: | Stig S. Bakken | Date: | Tue, 05 Feb 2002 12:56:17 +0000 |
| Subject: | Re: About DB class. | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-4535@lists.php.net to get a copy of this message | ||
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().
A caveat is of course that you lose all resource context (results,
uncommitted transactions), but I guess you can live with that.
- Stig