You are here

protected function Connection::doEscape in Drupal 8

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