Re: [PHP-DB] array field type

2007-03-06 Thread Tony Marston

Sancar Saran [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 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.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

 I just want to know is there any way to keep array data type natively in a 
 sql
 field.

 Regards.

 Sancar 

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



Re: [PHP-DB] array field type

2007-03-06 Thread Micah Stevens


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.


  
Sort of, but not really: This is a really specialized keyword, and 
depends on binary mapping of enum-ish sets. As a results you have a 
maximum of 64 possible values, and only 1 dimension. Large or 
multdimensional arrays wouldn't work with this.


-Micah

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



Re: [PHP-DB] array field type

2007-03-06 Thread Mark
Sancar Saran wrote:

 Thanks for all those replies. It seems there was no easy solution (and or
 serializing was better solution) for us.
 
 Our arrays contains lots of things.. XML may not fit because content of
 array may broke xml structure.
 

Before you give up, take a look at the XMLDBX PHP extension at
http://www.mohawksoft.org

It uses XML and works really well.

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



Re: [PHP-DB] array field type

2007-03-05 Thread Bastien Koert

another option might be to store xml snippets that match the array.

if you are using large numbers of arrays, perhaps a revamping of the db 
structure to map the arrays to sub-tables might be in order


bastien



From: Micah Stevens [EMAIL PROTECTED]
To: Sancar Saran [EMAIL PROTECTED]
CC: php-db@lists.php.net,  php-general@lists.php.net
Subject: Re: [PHP-DB] array field type
Date: Sun, 04 Mar 2007 15:04:42 -0800

Not a single field, but there's several methods of storing trees of 
information, which is what an array is. Here's one:


Nested Array storage table:

ArrayID (int, autonumber)
keyname (text)
parent   (int)
data (bigtext or whatever would be appropriate for the data you're storing)

For an array like this:

array('one'=1, 'two'=array('three'=3, 'four'=4))

the table would store these rows:

1, 'one', 0, 1
2, 'two', 0, 2
3, 'three', 2, 3
4, 'four', 2, 4

You can use a recursive function to restore the array, unless you require 
the granular functionality this type of process would give you such as 
sorting and filtering and statistics gathering.


-Micah

However, I think in the long run, you'd be better off serializing the data.

-Micah


On 03/04/2007 02: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




_
Win a trip for four to a concert anywhere in the world! 
http://www.mobilelivetour.ca/


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



Re: [PHP-DB] array field type

2007-03-05 Thread Sancar Saran
Thanks for all those replies. It seems there was no easy solution (and or 
serializing was better solution) for us.

Our arrays contains lots of things.. XML may not fit because content of array 
may broke xml structure. 

Thanks for help.

Regards

Sancar.

 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

 _
 Win a trip for four to a concert anywhere in the world!
 http://www.mobilelivetour.ca/

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



[PHP-DB] array field type

2007-03-04 Thread Sancar Saran
Hi,

I want to know is there any db server around there for store php arrays 
natively.

Regards

Sancar

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



Re: [PHP-DB] array field type

2007-03-04 Thread Sancar Saran
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

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



Re: [PHP-DB] array field type

2007-03-04 Thread Micah Stevens
Not a single field, but there's several methods of storing trees of 
information, which is what an array is. Here's one:


Nested Array storage table:

ArrayID (int, autonumber)
keyname (text)
parent   (int)
data (bigtext or whatever would be appropriate for the data you're storing)

For an array like this:

array('one'=1, 'two'=array('three'=3, 'four'=4))

the table would store these rows:

1, 'one', 0, 1
2, 'two', 0, 2
3, 'three', 2, 3
4, 'four', 2, 4

You can use a recursive function to restore the array, unless you 
require the granular functionality this type of process would give you 
such as sorting and filtering and statistics gathering.


-Micah

However, I think in the long run, you'd be better off serializing the data.

-Micah


On 03/04/2007 02: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