RE: [PHP-DB] Storing an array in the database

2003-02-28 Thread Hutchins, Richard
You could store it as a series of comma separated values in a text field and manipulate it using implode() and explode() on the comma separators. I've done this for small arrays and it works OK. WOuld like to know if there's an easier way though. Not that this is all that bad. I'm just lazy. ;^)

Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread Terry Romine
just as a quick fix. I use the following snip to take an array of choices, enter it into a varchar field (or text if you expect alot) and extract back to array: $choicesArray is a list of checkboxes from a form // put data into table $checkList = implode(;, $choicesArray);

Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread Ignatius Reilly
If your array is multidimensional, you could store it in a javascript-style: // get the print_r() // replace (recursively) all instances of Array( .. ) by [...] If you ever plan to write a class or a function to do that, let me know! Ignatius -

Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread Chris Boget
How would I store an array in the database? I want to store 2 things. One array of shirt sizes and one array of which holds other arrays. Easy. script language=php $singleDimArray = array( 1, 2, 3, 4, 5 ); $multiDimArray = array( array( this = that, here = there ),

RE: [PHP-DB] Storing an array in the database

2003-02-28 Thread Jonathan Villa
To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Storing an array in the database How would I store an array in the database? I want to store 2 things. One array of shirt sizes and one array of which holds other arrays. Easy. script language=php $singleDimArray = array( 1, 2, 3, 4, 5

Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread 1LT John W. Holmes
How would I store an array in the database? I want to store 2 things. One array of shirt sizes and one array of which holds other arrays. $safe = addslashes(serialize($array)); and store $safe into a text column. Use $array = unserialize($database_data); to get the array back. ---John

Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread 1LT John W. Holmes
How would I store an array in the database? I want to store 2 things. One array of shirt sizes and one array of which holds other arrays. [snip] $query = INSERT INTO table ( field1, field2 ) VALUES ( \ . serialize( $singleDimArray ) .

Re: [PHP-DB] Storing an array in the database

2003-02-28 Thread Chris Boget
FYI: Make sure you addslashes() _after_ you serialize your array if it can contain quotes. Everything else remains the same. Yeah, my bad. Good catch. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php