Page 1 of 1

an array inside a mysql table

Posted: Thu Sep 30, 2004 12:14 pm
by dsdsdsdsd
hello;

I have a table, the_table:
_____________________________
|column_1 |
|---------------------------------------|
|("index_1"=>"doo-hicky-A") |
|________________________|
that is a php associative array within a field;

ofcourse I can mysql:SELECT * FROM THE_TABLE and return it to the php script, do whatever I need to do inside the array with php, and then mysql:UPDATE THE_TABLE ... ;

however what I would like to do is have a table, ideal_table:
_______________________
|column_1 |
|-------------------------------|
|a mysql formatted array |
|______________________|

such that I can mysql:UPDATE IDEAL_TABLE SET COLUMN_1.INDEX_1 = 'DOO-HICKY-B' WHERE COLUMN_1.INDEX_1='DOO-HICKY-A'

any thoughts
thanks
Shannon Burnett

Posted: Thu Sep 30, 2004 12:41 pm
by feyd
afaik, mysql doesn't support what you are talking about.

you could instead, have 2 columns and then

Code: Select all

UPDATE SET column = 'thing2' WHERE column1 = 'index_1', column = 'thing1'

Posted: Thu Sep 30, 2004 2:43 pm
by dsdsdsdsd
feyd; thanks for your response;

Posted: Fri Oct 01, 2004 4:43 am
by AGISB
You could do the cheap mans array into one field solution of imploding the array into one string and than saving that string in a char, varchar or text column.

When reading you can explode it again into an array

Posted: Fri Oct 01, 2004 4:45 am
by feyd
can't correctly implode an associative array though ;)

Posted: Fri Oct 01, 2004 11:43 am
by AGISB
So true feyd. I should read the post more carefully