Hi! Thanx! /Gustav -----Original Message----- From: M. Sokolewicz [mailto:tularis@xxxxxxx] Sent: Tuesday, June 26, 2007 4:27 PM To: Gustav Wiberg Cc: 'Stut'; 'Dale Attree'; ''php windows'' Subject: Re: Save classes to db? http://www.php.net/manual/en/language.oop5.magic.php Gustav Wiberg wrote: > Hi again! > > I really can't find a manual for __sleep on the php.net site!? But I understand that __sleep is called before serialize and __wakeup is called before unserialize? > > Do you mean that I create a function __sleep in my class where I serialize my object and create a function __wakeup in my class where i unserialize my object? > > > > I was looking for a way to achieve this: (This maybe isn't possible?) > > 1. Save the serialized object into the database. > 2. Load the serialized object from database and unserialize and USE it. > (The problem is to USE it). > > > Best regards > /Gustav Wiberg > > > -----Original Message----- > From: Stut [mailto:stuttle@xxxxxxxxx] > Sent: Tuesday, June 26, 2007 3:42 PM > To: Gustav Wiberg > Cc: 'Dale Attree'; ''php windows'' > Subject: Re: Save classes to db? > > Gustav Wiberg wrote: >> Wouldn't it be possible to serialize the object in destructor of the class and unserialize from the constructor? > > As in serialize($this)?? Think about it for a while and you'll see why > that's not really a great idea. > > Firstly, where do you store the serialized object? > > Secondly, in the constructor you will be creating a new object, not > populating the current object. > > The sort of thing I think you're thinking about is the functionality > provided by __sleep and __wakeup. Look them up in the manual for full > details. > > Of course none of that changes the fact that you cannot serialize resources. > > -Stut > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php