public function Connection::prepareQuery in Zircon Profile 8
Same name in this branch
- 8 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::prepareQuery()
- 8 core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php \Drupal\Core\Database\Driver\sqlite\Connection::prepareQuery()
- 8 core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php \Drupal\Core\Database\Driver\pgsql\Connection::prepareQuery()
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php \Drupal\Core\Database\Driver\pgsql\Connection::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
\Drupal\Core\Database\StatementInterface A PDO prepared statement ready for its execute() method.
Overrides Connection::prepareQuery
File
- core/
lib/ Drupal/ Core/ Database/ Driver/ pgsql/ Connection.php, line 144 - Contains \Drupal\Core\Database\Driver\pgsql\Connection.
Class
- Connection
- PostgreSQL implementation of \Drupal\Core\Database\Connection.
Namespace
Drupal\Core\Database\Driver\pgsqlCode
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));
}