On Mon, 2004-08-09 at 19:29, Hardik Doshi wrote: > Hello Group, > > I would like to know which one is the most appropriate > way to implement the following scenario. > > For example, I want to display a products catalogue of > 100 products. I do have a base class of product which > contains all the basic property of the product > (Product title, product description, product price > etc)and constructor basically pulls the information > about the product from the DB based on the product > identifier (Primary key). > > Now i have two ways to display catalogue. > > 1. I can write only one query to pull all 100 products > information and store product information to each > product object (With out passing product id to the > constructor) into the collection and later i iterate > that collection to display product catalogue. > (Advantage: less communication with database server > and disadvantage: memory consumption is higher) >
You can do both. You can create an object for products and have it designed to give you details for a specific product, and then you can have a function that will return products based on a filter... (sometimes your users want to search for products)..so the same query can be used but append a filter to it. > 2. I can initiate an individual product object by > passing product id into the constructor and > constructor will pull an individual product > information from the DB and at the same time i can > display it (Disadvantage: Lots of communication with > database server and Advantage: memory consumption is > less) If you think about inheritance then eventually > this approach will have lots of database calls. > > Please guide me as i am stuck up which way to go. > > Let me know if you need more information. > > Thanks, > Hardik > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail Address AutoComplete - You start. We finish. > http://promotions.yahoo.com/new_mail -- /*************************************** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting & Development ****************************************/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php