storing and retrieving arrays in mysql

From: Date: Mon, 28 Jan 2002 20:56:08 +0000
Subject: storing and retrieving arrays in mysql
Groups: php.db 
Request: Send a blank email to php-db+get-16262@lists.php.net to get a copy of this message
Hi folks, I've got a question hopefully someone can shed some light on for me. I'm building an online store for a client, and one of the things he wants is to organize his products into categories and subcategories.. not so unusual, but the kicker is he wants to be able to associate a subcategory with more than one category. I was thinking that I should be able to easily serialize an array of cat_IDs and store it, but my concern is that this will sacrifice a great deal of flexibility when retrieving the data. For instance when I want to get the subcategories in a single category, I would pretty much have to select ALL the rows in the subcategory table, unserialize the category array for each row, and then check each to see if the cat_ID is in the array..? That just feels inefficient to me, and I'm almost certain I must be overlooking something simpler.. Also, I don't think I can use a SET data type because I want to be able to add values to the set (categories) dynamically in the future. But maybe I'm wrong and there is a way to do that...? Anyway I thought I'd throw it to those more experienced than me before I started coding. Anyone have any ideas? Thanks in advance, Corey Eiseman Infinite Orange Incorporated http://infiniteorange.com/

« previous php.db (#16262) next »