TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-03-2008, 05:46 PM   #1 (permalink)
The Contributor
 
abiko's Avatar
 
Join Date: Feb 2008
Location: Croatia
Posts: 90
Thanks: 4
abiko is on a distinguished road
Default Filters [database]

I'm wondering how to make dynamic filtering for content.
Example:
I want to have several categories(with subcategories) in which I want to place some articles (some kind of tags).
Filter
Code:
 Color
 ..../White
 ..../Black
 ..../Yellow
 Type
 ..../Box
 ..../Bag
 ..../Unknown
I though I would make one table where filers will be stored and another table in what will be applied filter.
Filter table
Code:
id | filter_name | filter_parent
Filter storage
Code:
filter_id | content_id
I want to be able to filter out content with multiple filter categories.
Example:
I want to find all White Boxes - so I need the content ids which match color:white and type:box.
So I have 25 "white" items and 12 "box" items. So do I compare the two arrays and get the array with my "filter" result and then query the content table with these ids?

This means I need about 3 queryes
1 to get the color filter, 1 to get the type filter and 1 to get the data out of the content table.
Now this expands rapidly if I want to filter out using 5 filters so I get 5+1 query - real stress for the DB.

Can you help me out with this? :)
__________________
Back from sysadmins to the programmers.
Send a message via ICQ to abiko Send a message via MSN to abiko
abiko is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:50 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design