Page 1 of 1

what is the best way to deal with the DB?

Posted: Thu Jul 12, 2012 11:48 pm
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?

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

Posted: Fri Jul 13, 2012 6:25 am
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?

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

Posted: Sat Jul 14, 2012 11:59 am
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.

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

Posted: Sat Jul 14, 2012 12:21 pm
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.

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

Posted: Wed Jul 18, 2012 11:36 am
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.