protected static function Connection::getSQLState in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::getSQLState()
Extracts the SQLSTATE error from the PDOException.
Parameters
\Exception $e: The exception
Return value
string The five character error code.
1 call to Connection::getSQLState()
- Connection::open in core/
lib/ Drupal/ Core/ Database/ Driver/ pgsql/ Connection.php - Opens a PDO connection.
File
- core/
lib/ Drupal/ Core/ Database/ Connection.php, line 1559
Class
- Connection
- Base Database API class.
Namespace
Drupal\Core\DatabaseCode
protected static function getSQLState(\Exception $e) {
// The PDOException code is not always reliable, try to see whether the
// message has something usable.
if (preg_match('/^SQLSTATE\\[(\\w{5})\\]/', $e
->getMessage(), $matches)) {
return $matches[1];
}
else {
return $e
->getCode();
}
}