protected static function Connection::getSQLState in Drupal 9
Same name and namespace in other branches
- 8 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 1956
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();
}
}