Re: Storing serialized classes in database

From: Date: Mon, 09 Jul 2001 18:34:36 +0000
Subject: Re: Storing serialized classes in database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-56992@lists.php.net to get a copy of this message
When you serialize() an object in PHP, it only stores the properties, not the methods. This way you can change any of the methods in your class definitions, or add new properties, and when the data is unserialize()d, it will fit into the new class definition. The latest (development) version of Pecos (http://pecos.screwdriver.net/) (which should, incidentally, be released later today or tomorrow) has moved from using entirely serialized() data to having a seperate table for storing properties. Basically, we loop through the object using get_object_vars() and store each property (serialized() only if it was an array or another object) seperately in a seperate field. This approach allows you to search by property rather than having to do a full-text search of the serialize()d data (or even worse, loading up each object and searching through it manually). -- /chris/ On Monday, July 9, 2001, at 10:58 AM, Michael Champagne wrote:
We are writing a series of applications which will store a user 'profile' between sessions as a serialized object in our Oracle database. We're storing data like the output format a user prefers file downloads in and things like that. If have to add certain things to this class, I'm assuming the serialized objects in the database become unusable. Does anyone have a good solution for this? I suppose we could go through the database and somehow convert these serialized 'profiles' to meet the new class spec. How much of a hassle is that? Thanks in advance for any responses, Michael Champagne, Software Engineer Capital Institutional Services, Inc. wk: mchampagne@capis.com hm: mchamp@texas.net


« previous php.general (#56992) next »