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?
what is the best way to deal with the DB?
Moderator: General Moderators
- 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?
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?
> 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?
Re: what is the best way to deal with 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.ZetCoby wrote:all i wan is to use the DB less not using a query every time i need some info from the DB
- 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?
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)
- 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?
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.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 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.