Re: mySQL searching through serialized arrays
| From: | Jason Wong | Date: | Thu, 09 Sep 2004 11:42:42 +0000 |
| Subject: | Re: mySQL searching through serialized arrays | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-36134@lists.php.net to get a copy of this message | ||
On Tuesday 07 September 2004 12:14, rolando g wrote:
> I am storing array of user IDs as TEXT using the serialize() function
> on the array, since several users, one or none can be part of each
> record...
>
> and I noticed that the serialized array has the values in double
> quotes like :"21"; for example... so since I know that the values
> will be enclosed, i am using the sql statement, with 21 as the
> example variable:
>
> SELECT FROM table WHERE userarray LIKE '%\"21\"%'
>
> is there a better way or a built-in mySQL function to filter through
> the serialized array
You're not using the database properly. Have a separate table where each
record contains a user_id and the record_id to which it is linked.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
T-shirt:
Life is *not* a Cabaret, and stop calling me chum!
*/