6
db_update('warrior_members')
          ->fields(array('points' => 'points' +1))//This is not working
          ->condition('uid', $liv_user)
          ->execute();

How to increase the cell at 1?

Sorry for my bad English

1 Answer 1

12

You want to use an expression: http://api.drupal.org/api/drupal/includes--database--query.inc/function/UpdateQuery%3A%3Aexpression/7

Example:

db_update('warrior_members')
  ->expression('points', 'points + 1')
  ->condition('uid', $liv_user)
  ->execute();

Or to make the 1 dynamic:

db_update('warrior_members')
  ->expression('points', 'points + :amount', array(':amount' => 1))
  ->condition('uid', $liv_user)
  ->execute();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.