mysql - Updating user profile efficiently -


something came mind , i'd bounce off:

say have user profile, 10 fields user can edit, , not of them required. when issuing update commands, more efficient either:

a) collect of fields, filled in or not, , issue 1 encompassing update statement server's db

or

b) use client side validation check see fields have been filled out or changed, , have selection of sql methods send , update these fields

or

c) create groupings, "updaterequiredfields(...) , updateextrafields(...)", issue 1 smaller transfer if changes belong in 1 group, 2 transfers if both edited

general consensus? option b far more verbose approach, i'm wondering if it's worth coding out or if it'll make noticeable impact on server (think "scaled big data").

you on db update function:

public function updatefields(array $fields) {    $updatequery = array();    foreach($fields $fieldkey => $fieldvalue) {       //if $fieldvalue false, leave unchanged       if ($fieldvalue !== false) {          //note: make sure escape or use pdo          $updatequery[] = $fieldkey . '=' . $fieldvalue;        }    }     $query = 'update userinfo set ' . implode(",", $updatequery) . ' ...'; } 

you need build $fields array based on modified on client side , pass in either new value or false if no change.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -