Re: Storing data structires in DB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> You are looking for serialize here. I bet you'd be better off with an
> existing XML format for something like this though.

WDDX is an unusual extension for most of the hosting providers. And writing my own XML serialization mechanism is an overkill. Moreover, XML is not-compact, harder to edit and probably slower to parse.

Compare this:

<wddxPacket version='1.0'><header comment='PHP'/><data><struct>
<var name='pi'><number>3.1415926</number></var><var name='cities'>
<array length='3'><string>Austin</string><string>Novato</string>
<string>Seattle</string></array></var></struct></data></wddxPacket>

(taken from php manual)

to this

a:2:{i:0;d:3.14159260000000006840537025709636509418487548828125;i:1;a:3:{i:0;s:6:"Austin";i:1;s:6:"Novato";i:2;s:6:"Seattle";}}

(Number is given exactly as it was output by serialize. What a happy coincidence.)

and to this

array(3.1415926,array('Austin','Novato','Seattle'))

(which could be reduced even more by elliminating the outer array() statement)

I'm surprised that there is no way to safely serialize and unserialize things using the same syntax as PHP itself uses. I can, of course, write PHP data structure parser in PHP, but that's twisted way of doing it, and it will be *slow*.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux