You are here

public static function SimplePopupBlocksStorage::update in Simple Popup Blocks 8

Same name and namespace in other branches
  1. 8.2 src/SimplePopupBlocksStorage.php \Drupal\simple_popup_blocks\SimplePopupBlocksStorage::update()

Update an entry in the database.

Parameters

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

Connection $database: Connection object.

Messenger $messenger: Messenger object.

Return value

int The number of updated rows.

See also

\Drupal\Core\Database\Connection::update()

1 call to SimplePopupBlocksStorage::update()
SimplePopupBlocksEditForm::submitForm in src/Form/SimplePopupBlocksEditForm.php
Form submission handler.

File

src/SimplePopupBlocksStorage.php, line 69

Class

SimplePopupBlocksStorage
Class SimplePopupBlocksStorage.

Namespace

Drupal\simple_popup_blocks

Code

public static function update(array $entry, Connection $database, Messenger $messenger) {
  $count = 0;
  try {

    // db_update()...->execute() returns the number of rows updated.
    $count = $database
      ->update('simple_popup_blocks')
      ->fields($entry)
      ->condition('pid', $entry['pid'])
      ->execute();
  } catch (\Exception $e) {
    $messenger
      ->addError(t('db_update failed. Message = %message, query= %query', [
      '%message' => $e
        ->getMessage(),
      '%query' => $e->query_string,
    ]));
  }
  return $count;
}