Serializing data
| From: | Brent Cook | Date: | Wed, 18 Sep 2002 05:51:24 +0000 |
| Subject: | Serializing data | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-9139@lists.php.net to get a copy of this message | ||
Hello,
I have functions DBA_Table that serialize/deserialize schema information
which is saved within a table. The functions, _packSchema($schema) and
_unpackSchema($schema), work well, but leave some things to be desired;
namely the reliance on punctuation marks for formatting and the absence of
string literal support (useful for default values of varchars and such).
Here's an example of output:
id;type=integer;auto_increment=1;default=2|name;type=varchar;size=45|notes;type=text|active;type=boolean|_rowid;type=integer;default=2;auto_increment=1|_timestamp;type=timestamp;default=time();default_type=function
Before I get into hacking these functions to work better and break
data-file compatibility again (DBA is still developmental), does anyone
have suggestions for other ways to serialize structured data (arrays)? I
had initially considered PHP's serialize/deserialize functions, but they
aren't cross-language (something important with data formats that would be
useful to access elsewhere), though I found a PERL parser for this here:
http://hurring.com/code/perl/serialize/
I've also been looking at wddx, which looks to be more amicable with other
languages. However, it may not be widely available with PHP installations
and I want to keep the prerequisites low.
What say you? Should I stick with my old methods, write new ones, or is
there something better?
- Brent