what is the best way to deal with the DB?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
ZetCoby
Forum Newbie
Posts: 10
Joined: Wed Sep 28, 2011 1:07 pm

what is the best way to deal with the DB?

Post by ZetCoby »

i wanna know what is the best way to deal with the database, by that i mean:
>>> if i have a huge project and every time a user logs on a page to view the goods that are for sale how can i make it so that if he goes to an other page and after a while return back to the goods page, i want that page not to take the info again from the DB but mantain it somewhere, all i want is to check if the DB has updated so only then the page should take the info again from the DB...
I dont reall know how to put this.... all i wan is to use the DB less not using a query every time i need some info from the DB
Is there a way to do this?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: what is the best way to deal with the DB?

Post by social_experiment »

ZetCoby wrote:
> i want that page not to take the info again from the DB but mantain it somewhere,
> all i want is to check if the DB has updated so only then the page should take the
> info again from the DB...
> I dont reall know how to put this.... all i wan is to use the DB less not using a
> query every time i need some info from the DB

I think you are describing something that the browser cache is already doing?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: what is the best way to deal with the DB?

Post by califdon »

ZetCoby wrote:all i wan is to use the DB less not using a query every time i need some info from the DB
You should not concern yourself with this. If a script needs info from the database, it must query the database to get it. If the data will be needed repeatedly during one browser session, you can assign the value to a session variable and other scripts should use the session variable rather than the database, but that is different from returning to a previously viewed page, which, as social_experiment said, should automatically be cached by the browser.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: what is the best way to deal with the DB?

Post by Christopher »

If you are talking about information about the user or the items they have selected, that can be stored in the session temporarily. If you are talking about the goods that are displayed, then you should get the info from the database each time.
(#10850)
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: what is the best way to deal with the DB?

Post by Bill H »

all i wan is to use the DB less not using a query every time i need some info from the DB
If you're worried about overworking the database, don't be; that's what they are designed for. Databases don't get tired or worn out.

If you're worried about the time it takes, don't be; it has to be a really, really, really, massive database or a totally botched query before the time to fetch the data becomes noticable to the viewer.

Edit: well, okay, or a really slow server, but in that case you need to change your hosting, not your scripting.
Post Reply