You are here

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

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

Load single popup from table with identifier.

2 calls to SimplePopupBlocksStorage::loadCountByIdentifier()
SimplePopupBlocksAddForm::validateForm in src/Form/SimplePopupBlocksAddForm.php
Form validation handler.
SimplePopupBlocksEditForm::validateForm in src/Form/SimplePopupBlocksEditForm.php
Form validation handler.

File

src/SimplePopupBlocksStorage.php, line 103

Class

SimplePopupBlocksStorage
Class SimplePopupBlocksStorage.

Namespace

Drupal\simple_popup_blocks

Code

public static function loadCountByIdentifier($identifier, Connection $database, Messenger $messenger) {
  try {
    $select = $database
      ->select('simple_popup_blocks', 'pb');
    $select
      ->fields('pb', [
      'pid',
    ]);
    $select
      ->condition('identifier', $identifier);

    // Return the result in object format.
    // countQuery()->execute()->fetchField();//
    return $select
      ->execute()
      ->fetchAll();
  } catch (\Exception $e) {
    $messenger
      ->addError(t('db_select loadCountByIdentifier failed. Message = %message, query= %query', [
      '%message' => $e
        ->getMessage(),
      '%query' => $e->query_string,
    ]));
  }
}