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)

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 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to