Hi! Ok, thanx! 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 -- http://stut.net/ > -----Original Message----- > From: Stut [mailto:stuttle@xxxxxxxxx] > Sent: Tuesday, June 26, 2007 3:29 PM > To: Dale Attree > Cc: 'Gustav Wiberg'; ''php windows'' > Subject: Re: Save classes to db? > > Dale Attree wrote: >> Hi there, >> >> You would use a blob or text field. >> >> You will have to serialize the object before saving it to db. >> >> Then when you retrieve it, you will have to deserialize it and then eval() >> the object so as to active all the values. > > It's unserialize not deserialize, and there's no need to eval anything, > just make sure you have either included the class definition before > unserializing it or have an __autoload function defined. > > Remember that you cannot serialize resources, so you must make sure you > close any open resources in the __sleep method, and you can recreate > them during unserialize using a __wake method. > > -Stut > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php