You are here

public function Connection::prepareQuery in Zircon Profile 8

Same name in this branch
  1. 8 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::prepareQuery()
  2. 8 core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php \Drupal\Core\Database\Driver\sqlite\Connection::prepareQuery()
  3. 8 core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php \Drupal\Core\Database\Driver\pgsql\Connection::prepareQuery()
Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\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.

2 calls to Connection::prepareQuery()
Connection::prepareQuery in core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
Prepares a query string and returns the prepared statement.
Connection::query in core/lib/Drupal/Core/Database/Connection.php
Executes a query string against the database.
2 methods override Connection::prepareQuery()
Connection::prepareQuery in core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
Prepares a query string and returns the prepared statement.
Connection::prepareQuery in core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
Prepares a query string and returns the prepared statement.

File

core/lib/Drupal/Core/Database/Connection.php, line 391
Contains \Drupal\Core\Database\Connection.

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function prepareQuery($query) {
  $query = $this
    ->prefixTables($query);
  return $this->connection
    ->prepare($query);
}