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

Breadcrumb

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

function Connection::prepareStatement

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::prepareStatement()
  2. 11.1.x core/modules/sqlite/src/Driver/Database/sqlite/Connection.php \Drupal\sqlite\Driver\Database\sqlite\Connection::prepareStatement()

Overrides Connection::prepareStatement

File

core/modules/pgsql/src/Driver/Database/pgsql/Connection.php, line 249

Class

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

Namespace

Drupal\pgsql\Driver\Database\pgsql

Code

public function prepareStatement(string $query, array $options, bool $allow_row_count = FALSE) : StatementInterface {
    // mapConditionOperator converts some operations (LIKE, REGEXP, etc.) to
    // PostgreSQL equivalents (ILIKE, ~*, etc.). However PostgreSQL doesn't
    // automatically cast the fields to the right type for these operators,
    // so we need to alter the query and add the type-cast.
    $query = preg_replace('/ ([^ ]+) +(I*LIKE|NOT +I*LIKE|~\\*|!~\\*) /i', ' ${1}::text ${2} ', $query);
    return parent::prepareStatement($query, $options, $allow_row_count);
}

API Navigation

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