You are here

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

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

Save an entry in the simple_popup_blocks table.

Parameters

array $entry: An array containing all the fields of the database record.

Connection $database: Connection object.

Messenger $messenger: Messenger object.

Return value

int The number of updated rows.

Throws

\Exception When the database insert fails.

See also

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

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

File

src/SimplePopupBlocksStorage.php, line 35

Class

SimplePopupBlocksStorage
Class SimplePopupBlocksStorage.

Namespace

Drupal\simple_popup_blocks

Code

public static function insert(array $entry, Connection $database, Messenger $messenger) {
  $return_value = NULL;
  try {
    $return_value = $database
      ->insert('simple_popup_blocks')
      ->fields($entry)
      ->execute();
  } catch (\Exception $e) {
    $messenger
      ->addError(t('db_insert failed. Message = %message, query= %query', [
      '%message' => $e
        ->getMessage(),
      '%query' => $e->query_string,
    ]));
  }
  return $return_value;
}