Let's assume my application creates a list of products, depending on their respective price and amount of 1-star ratings they have. So it needs two parameters:
-A price-range, ussually modelled as a tuple/array with two int entries/or whatever else there is.
-A limit of how many 1-star ratings there can be. Example: If there is a limit of 5 1star ratings, products with 8 1star ratings won't get displayed.
Now, there's still the option of having no limit at all, and display products of all prices, which obviously affects the query to the database. To implement such a limit, I've often simply used if-conditionals: If the range is between 0 and 0,show all. If the limit is -1,remove the limit.
Thing is, this is ugly.
How would one properly implement the concept of no limit?
For the record, I'm coding a web app with PHP, using a MySQL database.
Aucun commentaire:
Enregistrer un commentaire