You are here

protected function MenuTreeStorage::safeExecuteSelect in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::safeExecuteSelect()

Executes a select query while making sure the database table exists.

Parameters

\Drupal\Core\Database\Query\SelectInterface $query: The select object to be executed.

Return value

\Drupal\Core\Database\StatementInterface|null A prepared statement, or NULL if the query is not valid.

Throws

\Exception Thrown if the table could not be created or the database connection failed.

1 call to MenuTreeStorage::safeExecuteSelect()
MenuTreeStorage::menuNameInUse in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Determines whether a specific menu name is used in the tree.

File

core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 245
Contains \Drupal\Core\Menu\MenuTreeStorage.

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

protected function safeExecuteSelect(SelectInterface $query) {
  try {
    return $query
      ->execute();
  } catch (\Exception $e) {

    // If there was an exception, try to create the table.
    if ($this
      ->ensureTableExists()) {
      return $query
        ->execute();
    }

    // Some other failure that we can not recover from.
    throw $e;
  }
}