function Connection::getSQLState
Same name in other branches
- 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::getSQLState()
- 8.9.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::getSQLState()
- 10 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::getSQLState()
Extracts the SQLSTATE error from a PDOException.
Parameters
\Exception $e: The exception
Return value
string The five character error code.
1 call to Connection::getSQLState()
- Connection::open in core/
modules/ pgsql/ src/ Driver/ Database/ pgsql/ Connection.php - Opens a client connection.
File
-
core/
lib/ Drupal/ Core/ Database/ Connection.php, line 1282
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();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.