• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP best way to update db... use caching?

Alex

Diamond Member
i'm working on a website with a very large amount of "user profile" information...

i created a couple classes to handle manipulation of the user's profile in an easier way and so far it works great but i have a problem with updating the information:

when the user changes something i can either run a seperate query for every field that he changes or i just wait till he's done and run a "update all" query when he exits the edit page. the problem with the second option is that if he has some kind of internet problem or leaves the website unexpectedly then none of the changes would be saved...

what's the best way to get around this? i would have to have to run a seperate query every time but i know how annoying it can be to spend some time filling out a form only to have something happen and you lose your input... thanks!
 
Originally posted by: troytime
is your user interface not a form with a submit button?

yes... but that doesn't really change anything, right now i just update the object's variables with the submit and there's a "save changes" button that updates the database from the variables in 1 query

 
so you just want to do a little extra hand-holding?

the user will update the form with new data, it may take them 30 minutes, when they click submit they realize that they're not online anymore...

is this your concern?

how many form inputs are on the page?
 
maybe i haven't explained it very well... there's a page with around 15 forms where the user can view and edit his profile information.

my main concern is when should I update the database; after every field changes or once when the user exits the page.

if i update every time the user changes a value, i'll have run around 15 queries to update everything individually.
if i update only once at the end it's only 1 query.

if the user updates half the stuff and gets a phone call or something and stops editing the page for a while i'm afraid his session will expire or something and he will have lost half of his input, because i would have only updated it at the end... see what i mean?
 
ok now i get it - sorry, allergies are murdering me slowly 🙂

just do one query upon form submission

if session timeout is a concern, set a javascript timer to alert the user if the timeout is near
(don't actually use the javascript alert though, those are annoying, just have a hidden div and have the javascript unhide it)
 
Originally posted by: troytime
if session timeout is a concern, set a javascript timer to alert the user if the timeout is near
(don't actually use the javascript alert though, those are annoying, just have a hidden div and have the javascript unhide it)

I've never done this myself, but couldn't you use javascript to send meaningless requests to the server to keep the session alive?

I just set the session timeout on my server high enough to avoid that whole deal. Unless you have a ton of users, that shouldn't be a big deal.
 
Originally posted by: mugs
Originally posted by: troytime
if session timeout is a concern, set a javascript timer to alert the user if the timeout is near
(don't actually use the javascript alert though, those are annoying, just have a hidden div and have the javascript unhide it)

I've never done this myself, but couldn't you use javascript to send meaningless requests to the server to keep the session alive?

I just set the session timeout on my server high enough to avoid that whole deal. Unless you have a ton of users, that shouldn't be a big deal.


that might be possible, i never use sessions though so i'm not sure
i stick with cookies 🙂
 
Originally posted by: troytime
Originally posted by: mugs
Originally posted by: troytime
if session timeout is a concern, set a javascript timer to alert the user if the timeout is near
(don't actually use the javascript alert though, those are annoying, just have a hidden div and have the javascript unhide it)

I've never done this myself, but couldn't you use javascript to send meaningless requests to the server to keep the session alive?

I just set the session timeout on my server high enough to avoid that whole deal. Unless you have a ton of users, that shouldn't be a big deal.


that might be possible, i never use sessions though so i'm not sure
i stick with cookies 🙂

well that would stop expired sessions but not just closing the browser or going to another website kinda deal... i think i'm just gonna leave it as it is and have a big button with big red fonts saying "APPLY CHANGES" like windows 😀
 
Originally posted by: alex
Originally posted by: troytime
Originally posted by: mugs
Originally posted by: troytime
if session timeout is a concern, set a javascript timer to alert the user if the timeout is near
(don't actually use the javascript alert though, those are annoying, just have a hidden div and have the javascript unhide it)

I've never done this myself, but couldn't you use javascript to send meaningless requests to the server to keep the session alive?

I just set the session timeout on my server high enough to avoid that whole deal. Unless you have a ton of users, that shouldn't be a big deal.


that might be possible, i never use sessions though so i'm not sure
i stick with cookies 🙂

well that would stop expired sessions but not just closing the browser or going to another website kinda deal... i think i'm just gonna leave it as it is and have a big button with big red fonts saying "APPLY CHANGES" like windows 😀

is your application really built for complete intarweb newbs?
 
Back
Top