[PHP] Minimizing Database Hits

2003-07-01 Thread Ralph
I wrote class that contains a function that retrieves users shopping
cart items from database and then returns an array with qty, item number
, item name, etc.

So now whenever I want to retrieve the users cart I use the following:

$cart_contents = $cart-get_cart_contents();

I then iterate through $cart_contents to display info. Now I am trying
to minimize the number of hits to the database so my question is, am I
querying the database every time I call on $cart_contents?



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



Re: [PHP] Minimizing Database Hits

2003-07-01 Thread Ray Hunter
Only if your code is calling the database...if $cart_contents is set on
the page and you call the var $car_contents over and over then no...the
initialization of the var is the only time if it is called in
get_cart_contents()...

--
BigDog

On Tue, 2003-07-01 at 16:41, Ralph wrote:
 I wrote class that contains a function that retrieves users shopping
 cart items from database and then returns an array with qty, item number
 , item name, etc.
 
 So now whenever I want to retrieve the users cart I use the following:
 
 $cart_contents = $cart-get_cart_contents();
 
 I then iterate through $cart_contents to display info. Now I am trying
 to minimize the number of hits to the database so my question is, am I
 querying the database every time I call on $cart_contents?
 
 


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



Re: [PHP] Minimizing Database Hits

2003-07-01 Thread Andrew McCombe


 I wrote class that contains a function that retrieves users shopping
 cart items from database and then returns an array with qty, item number
 , item name, etc.

 So now whenever I want to retrieve the users cart I use the following:

 $cart_contents = $cart-get_cart_contents();

 I then iterate through $cart_contents to display info. Now I am trying
 to minimize the number of hits to the database so my question is, am I
 querying the database every time I call on $cart_contents?

One way of doing this is to store the shopping cart as  session data and
using  a class to read the session rather than the DB.  Doing it this way
means that the DB is only accessed before the shopper puts the item in their
cart.  Once it's there, the sesion holds the data and the DB load is
reduced.  We use this system in many of our sites.


Regards
Andrew


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