RE: [PHP-WIN] Save classes to db?

From: Date: Tue, 26 Jun 2007 14:28:00 +0000
Subject: RE: [PHP-WIN] Save classes to db?
Groups: php.windows 
Request: Send a blank email to php-windows+get-28153@lists.php.net to get a copy of this message
Hi! Thanx! /Gustav -----Original Message----- From: M. Sokolewicz [mailto:tularis@php.net] Sent: Tuesday, June 26, 2007 4:27 PM To: Gustav Wiberg Cc: 'Stut'; 'Dale Attree'; ''php windows'' Subject: Re: [PHP-WIN] 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@gmail.com] > Sent: Tuesday, June 26, 2007 3:42 PM > To: Gustav Wiberg > Cc: 'Dale Attree'; ''php windows'' > Subject: Re: [PHP-WIN] 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 >

« previous php.windows (#28153) next »