pretty urls + ugly database design
Posted: Thu Sep 28, 2006 1:31 pm
Alright... this is another issue with a terribly designed database schema... just looking for some advice. I am using pretty urls in a directory I am building, but I have to use the category names as my where clause because categories don't have ids in the terrible schema. So... I am using the function I found in scottay's thread about pretty urls...
This works exactly how I would like it to... but the problem now is that I can't search my database for a category like "health-foods-and-servicesnutritional-products" when in the database it's called "Health Foods & Services/Nutritional Products". Would it be a better idea to create an extra column in the table with the url-safe version of the category to search in... or should I just create a function that matches the url-safe category names to the ones in the database... or am I going about this wrong all-together?
Code: Select all
static public function cleanUrl($url) {
return
preg_replace('/[^a-z0-9-]/','',
preg_replace('/\s{1,}/','-',
preg_replace('/&/',' and ',
strtolower($url)
)));
}