Re: Storing an array in the database
| From: | 1LT John W. Holmes | Date: | Fri, 28 Feb 2003 16:50:00 +0000 |
| Subject: | Re: Storing an array in the database | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26006@lists.php.net to get a copy of this message | ||
> > 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 ) . "\", \""
> .
serialize( $multiDimArray ) . "\" )";
FYI: Make sure you addslashes() _after_ you serialize your array if it can
contain quotes. Everything else remains the same.
---John Holmes...