Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Connection.php

function 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\Database

Code

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();
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal