Re: Serialize...Unserialize
| From: | Gerard Samuel | Date: | Tue, 04 Mar 2003 18:38:45 +0000 |
| Subject: | Re: Serialize...Unserialize | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26091@lists.php.net to get a copy of this message | ||
Hutchins, Richard wrote:
I have an array of values I want to store in a MySQL db in a column called readBy of type TEXT. I want to take that array and serialize it then insert it into the db. No big deal. When I query the db and get the value from the readBy column, I know I have to unserialize it. Again, no big deal. My question about all of this is once I unserialize the data from the column, can I immediately use the array_push() function to append additional data to the unserialized data? I would imagine because the output of unserialize() is of the array type. Unless, there was an error unserializing it.
Will the unserialized data immediately be recognized/treated as an array? Yes.
Also, is the TEXT dolumn type an appropriate column type to store serialized data or is there another column type that should be used? If you can guarantee that the data doesn't go above 256 characters, then a varchar column can be used.But serialized data can get pretty big, so anticipate for it, by using text columns. -- Gerard Samuel http://www.trini0.org:81/ http://test1.trini0.org:81/