Re: Re: [PHP-DB] array field type

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

 



An array is a "multi-value field".  The standard way to do that in SQL is with 
a dependent table, something like this:

foo(fid, field_a, field_b, field_c);
foo_d(fid, value);

Or possibly: 

food_d(fid, delta, value);

where delta is essentially an array offset if you want to maintain ordering.

I don't know of a clean way to then load that data in all one query.  Each 
dependent table then becomes another simple query, and you link the data up 
in a PHP data structure of some sort.

Modifying the "array" can then get expensive as well.  If you don't have a 
delta, then a delete/insert cycle to change the values is generally the 
easiest solution.  If you do have a delta, then you may be able to 
individually identify and delete/update values in the "array" by fid and 
delta as the primary key.

On Sunday 04 March 2007 4:15 pm, Sancar Saran wrote:
> 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).
>
> I just want to know is there any way to keep array data type natively in a
> sql field.
>
> Regards.
>
> Sancar

-- 
Larry Garfield			AIM: LOLG42
larry@xxxxxxxxxxxxxxxx		ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

-- 
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