function Connection::doEscape

Escape a string if needed.

Parameters

$string: The string to escape.

Return value

string The escaped string.

2 calls to Connection::doEscape()
Connection::escapeAlias in core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
Escapes an alias name string.
Connection::escapeField in core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
Escapes a field name string.

File

core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php, line 288

Class

Connection
PostgreSQL implementation of \Drupal\Core\Database\Connection.

Namespace

Drupal\Core\Database\Driver\pgsql

Code

protected function doEscape($string) {
    // Quote identifier to make it case-sensitive.
    if (preg_match('/[A-Z]/', $string)) {
        $string = '"' . $string . '"';
    }
    elseif (in_array(strtolower($string), $this->postgresqlReservedKeyWords)) {
        // Quote the string for PostgreSQL reserved key words.
        $string = '"' . $string . '"';
    }
    return $string;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.