NYCPHP Meetup

NYPHP.org

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

Hans Zaunere lists at zaunere.com
Sun Oct 22 12:00:49 EDT 2006


Hi Cliff,

Cliff Hirsch wrote on Sunday, October 22, 2006 7:08 AM:
> Is serializing/unserializing object/arrays for storage/retrieval in a
> MySQL db truly reliable? It would be awfully handy, but the PHP
> manual notes list various issues that make me wary.  

I would frankly recommend against it.  While it's possible if you're
careful, there can be a lot of surprises, such as:

-- unserialized objects aren't quite what you may expect them to be (ie, the
definition of the class either has changed or doesn't exist)

-- it's slow

-- it doesn't give you any type of normalization - ie, the object's data is
relationally useless - and you end up having to do text matching to find
anything

There are some other options, that may be better:

http://us3.php.net/wddx

Although it has it's downfalls too.  End of the day, I'd try to avoid
serializing objects - serializing arrays and scalar types, though not
optimized in PHP (ie, slow), is much more reliable.

---
Hans Zaunere / President / New York PHP
   www.nyphp.org  /  www.nyphp.com





More information about the talk mailing list