Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function DatabaseConnection_pgsql::prepareQuery

Prepares a query string and returns the prepared statement.

This method caches prepared statements, reusing them when possible. It also prefixes tables names enclosed in curly-braces.

Parameters

$query: The query string as SQL, with curly-braces surrounding the table names.

Return value

DatabaseStatementInterface A PDO prepared statement ready for its execute() method.

Overrides DatabaseConnection::prepareQuery

1 call to DatabaseConnection_pgsql::prepareQuery()
DatabaseConnection_pgsql::query in includes/database/pgsql/database.inc
Executes a query string against the database.

File

includes/database/pgsql/database.inc, line 77

Class

DatabaseConnection_pgsql

Code

public function prepareQuery($query) {
 // mapConditionOperator converts LIKE operations to ILIKE for consistency
 // with MySQL. However, Postgres does not support ILIKE on bytea (blobs)
 // fields.
 // To make the ILIKE operator work, we type-cast bytea fields into text.
 // @todo This workaround only affects bytea fields, but the involved field
 // types involved in the query are unknown, so there is no way to
 // conditionally execute this for affected queries only.
 return parent ::prepareQuery (preg_replace ('/ ([^ ]+) +(I*LIKE|NOT +I*LIKE) /i', ' ${1}::text ${2} ', $query));
}

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