NYCPHP Meetup

NYPHP.org

[nycphp-talk] Is serializing object/arrays for MySQL reliable?

Kenneth Downs ken at secdat.com
Mon Oct 23 14:31:03 EDT 2006


Dan Cech wrote:
> Daniel Convissor wrote:
>   
>> Hi Cliff:
>>
>> On Sun, Oct 22, 2006 at 07:08:11AM -0400, Cliff Hirsch wrote:
>>     
>>> Is serializing/unserializing object/arrays for storage/retrieval in a
>>> MySQL db truly reliable?
>>>       
>> Depends on what you're doing.  We use them to store history.  For example, 
>> our update method finds the diff between the old and new data.  The diff 
>> contains the old values that are about to be changed, in an associative 
>> array format with column names as the keys.  We then serialize that and 
>> store it in a history table along with the record id and table name.
>>     
>
> This is a pretty common use of serialized data, and one it is fairly
> well suited to.
>
> That said, I tend to use a simple xml format for storing these kinds of
> fields, for a few reasons.
>
> 1. UTF-8 encoding is easy in XML
> 2. XML is easy to read/edit manually if needed
> 3. It's harder to break and when you do, easier to fix
>
>   
I suppose somebody should chime in and point out that you can also store 
the historical data in POTS (plain old tables), on the theory that 
tabular information works best in tables.  Easier to write, easier to read.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20061023/8f03aece/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ken.vcf
Type: text/x-vcard
Size: 261 bytes
Desc: not available
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20061023/8f03aece/attachment.vcf>


More information about the talk mailing list