On this page
protected function MenuTreeStorage::safeExecuteSelect
protected MenuTreeStorage::safeExecuteSelect(SelectInterface $query)
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.
File
- core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 240
Class
- MenuTreeStorage
- Provides a menu tree storage using the database.
Namespace
Drupal\Core\MenuCode
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;
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!MenuTreeStorage.php/function/MenuTreeStorage::safeExecuteSelect/8.1.x