开发者

PHP coding a price comparaison tool

开发者 https://www.devze.com 2022-12-31 22:31 出处:网络
it\'s the first time I developp such tool you all know (the possibility to compare articles according to price and/or options)

it's the first time I developp such tool you all know (the possibility to compare articles according to price and/or options)

Since I never did that i want to tell me what do you think of the way i see that :

On the database we would have :

offer / price / option 1 / option 2 / option 3 / IDseller / IDoffer
best buy / 15$ / full FTP / web hosting / php.ini / 10 / 1
.../..../.... 

And the request made by the client :

"SELECT * FROM offers WHERE price <= 20 AND option1 = fullFTP"; 

I don't know if it seems OK to you.

P开发者_JAVA百科lus i was wondering, how to avoid multiples displays for the same seller (not on the DB but only on the front-end). Imagine you have multiple offers with a price <= 20 with the option FullFTP for the same seller, i don't want him to be shown 5 times on the comparator.

If you have any advices ;)

Thanks


You want to read about database normalization and 3rd normal form.

You may also need to timestamp your rows and include those ranges in your query.

You should move your options to a separate table and aggregate options with a deal in a associative table.

options (id, description)

sellers (id, name, description, ...)

offers (id, seller_id, title, description, price, entry_date, start_date, end_date)

offer_options (offer_id, option_id)

That gets you a lot closer to where you need to be and it will make things a lot easier.

Next... SQL joins


If you don't want that seller to be displayed multiple times use "GROUP BY IDseller" in your SQL.


To avoid showing multiple sellers, use the GROUP BY feature after your WHERE clause.

"SELECT * FROM offers WHERE price <= 20 AND option1 = fullFTP"; 

Make sure you filter within each vendor though. As far as I can tell, your initial setup is sound.

This question seems very general.


And why not use Apache Lucene to implement the front-end functionality ? The are Zend libraries that offer Lucene functionality in PHP.

Keep storing the data in your database, but export it also as a Lucene index.

Ok, this is price comparison, but it could make sense for options. Just put all your options in one field, comma-separated for example, and use text search.

0

精彩评论

暂无评论...
验证码 换一张
取 消