an array inside a mysql table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

an array inside a mysql table

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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'
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post by dsdsdsdsd »

feyd; thanks for your response;
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

can't correctly implode an associative array though ;)
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

So true feyd. I should read the post more carefully
Post Reply