Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2001072

Re: [PHP] issues with __sleep() and __wakeup() From: mike cullerton (michaelc <email protected>)
Date: 07/31/01

on 7/31/01 1:48 PM, scott [gts] at scott <email protected> wrote:

> I am having a problem with __sleep();
> there mere existance of it is causing my object
> to not get serialized at all. __wakeup() works fine.
>
> i am using PHP v4.0.6 / apache / win2k.
>
> If i keep __sleep() in the object, it will not serialize,
> but if i remove it, it serialized fine. Does anyone
> know why this happens?

i asked this about a month ago and didn't hear anything. i too have never
been able to get __sleep to work. i think it's because i couldn't figure out
what needed to be returned (or how to return it :)

at http://www.php.net/manual/en/language.oop.magic-functions.php it says
that __sleep is "supposed to return an array with the names of all variables
of that object that should be serialized", but there are no examples of
this.

in a current project, i have an object that is registed as a session
variable. it contains three objects and an array. one of the objects is a
PEAR db object, and i don't need to serialize it. i do want to maintain the
other two objects and the array.

i tried a number of ideas inside __sleep, to no avail. without __sleep, it
works. with __sleep, i break it.

i do use __wakeup to reinitialize my db object, but i just use
$db->disconnect(); at the end of my index file to disconnect .

does anyone know the proper way to "clean up the object" in __sleep and how
to return the variables that should be serialized? can this even be used
when one (or more) of the variables is an object itself?

thanks,
mike

 -- mike cullerton

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>