I have a cart class, where I store the product ids. The user can open the cart through a button that opens the cart in a popup, so the cart content has to be loaded in every page.
I can store only the ids of the products because of the size limits, but I want to show the product names to the final user, so for each element I need to make a query and get the product data from the database.
Is there any major drawback by doing this? Or are there better solutions?
PS: I could get the id of all the products in the cart, and then do one single query that gets the data of any needed product. I’d rather avoid this since I would need to rewrite parts of the class, so is there any actual difference with the previous solution?
PPS: The total number of sql queries shouldn’t be too high in any case. Of course I wouldn’t mind, but I strongly doubt any user will purchase hundreds of different products at one time.