Re: array field type
| From: | Mark | Date: | Tue, 06 Mar 2007 17:12:57 +0000 |
| Subject: | Re: array field type | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-249931@lists.php.net to get a copy of this message | ||
Myron Turner wrote:
> Tony Marston wrote:
>> "Sancar Saran" <sancar.saran@evodot.com> wrote in message
>> news:200703050015.50252.sancar.saran@evodot.com...
>>
>>> On Sunday 04 March 2007 23:04, Sancar Saran wrote:
>>>
>>>> Hi,
>>>>
>>>> I want to know is there any db server around there for store php arrays
>>>> natively.
>>>>
>>>> Regards
>>>>
>>>> Sancar
>>>>
>>> Thanks for responses, it seems I have to give more info about situation.
>>>
>>> In my current project, we had tons of arrays. They are very deep and
>>> unpredictable nested arrays.
>>>
>>> Currently we are using serialize/unserialize and it seems it comes
>>> with own
>>> cpu cost. Xdebug shows some serializing cost blips. Sure it was not
>>> SO BIG
>>> deal (for now of course).
>>>
>>> My db expertise covers a bit mysql and mysql does not have any array
>>> type
>>> field (enum just so simple).
>>>
>>
>> Wrong! Take a look at the SET datatype
>> http://dev.mysql.com/doc/refman/4.1/en/set.html. This
>> allows you to
>> have an array of values in a single field, and the user can select any
>> number of them.
>>
>>
> It might be worth looking at wddx. I can't speak about the cpu cost for
> large numbers of arrays, but it's mechanism is simple. It saves data
> types as XML strings, which can be written using
> **wddx_serialize_vars()* <cid:part1.05070903.01090402@shaw.ca> *and read
> using **wddx_deserialize()* <cid:part2.08060209.04020008@shaw.ca>.
WDDX is kind of dicey, it doesn't handle a lot of the data types correctly.
About a year an a half ago, I tried to use it as a serializer and it really
confused the datatypes in PHP. If you are doing something simple, it will
probably work, but I wouldn't count on it.
I have an extension to PHP that could work for you. Take a look at XMLDBX at
http://www.mohawksoft.org. You'll need to get it from
CVS. Put it in
the "ext" directory and run ./buildconf.sh --force, then configure
with --with-xmldbx
It started out as a fix to wddx, but essentially became a rewrite. I've been
using it on a few sites for over a year now.