You are here

public static function CartStorage::update in Basic cart 8

Same name and namespace in other branches
  1. 8.6 src/CartStorage.php \Drupal\basic_cart\CartStorage::update()
  2. 8.0 src/CartStorage.php \Drupal\basic_cart\CartStorage::update()
  3. 8.2 src/CartStorage.php \Drupal\basic_cart\CartStorage::update()
  4. 8.3 src/CartStorage.php \Drupal\basic_cart\CartStorage::update()
  5. 8.4 src/CartStorage.php \Drupal\basic_cart\CartStorage::update()
  6. 8.5 src/CartStorage.php \Drupal\basic_cart\CartStorage::update()

Update an entry in the database.

Parameters

array $entry: An array containing all the fields of the item to be updated.

Return value

int The number of updated rows.

See also

db_update()

File

src/CartStorage.php, line 61

Class

CartStorage
Class CartStorage.

Namespace

Drupal\basic_cart

Code

public static function update($entry) {
  try {

    // db_update()...->execute() returns the number of rows updated.
    $count = db_update(self::TABLE)
      ->fields($entry)
      ->condition('uid', $entry['uid'])
      ->condition('id', $entry['id'])
      ->condition('entitytype', $entry['entitytype'])
      ->execute();
  } catch (\Exception $e) {
    drupal_set_message(t('db_update failed. Message = %message, query= %query', array(
      '%message' => $e
        ->getMessage(),
      '%query' => $e->query_string,
    )), 'error');
  }
  return $count;
}