Update query in Drupal 7

Public

Update query in Drupal 7

Get raw version
php
  1. // Old code.
  2. db_query("UPDATE {profile_field} SET weight = %d, category = '%s' WHERE fid = %d", $weight, $category, $fid);
  3.  
  4. // DBTNG.
  5. db_update('profile_field')
  6. ->fields(array(
  7. 'weight' => $weight,
  8. 'category' => $category,
  9. ))
  10. ->condition('fid', $fid)
  11. ->execute();