Same name and namespace in other branches
  1. 4.7.x includes/database.pgsql.inc \db_query_temporary()
  2. 4.7.x includes/database.mysqli.inc \db_query_temporary()
  3. 4.7.x includes/database.mysql.inc \db_query_temporary()
  4. 5.x includes/database.pgsql.inc \db_query_temporary()
  5. 5.x includes/database.mysqli.inc \db_query_temporary()
  6. 5.x includes/database.mysql.inc \db_query_temporary()
  7. 6.x includes/database.pgsql.inc \db_query_temporary()
  8. 6.x includes/database.mysqli.inc \db_query_temporary()
  9. 6.x includes/database.mysql.inc \db_query_temporary()
  10. 7.x includes/database/database.inc \db_query_temporary()

Executes a SELECT query string and saves the result set to a temporary table.

The execution of the query string happens against the active database.

Parameters

string $query: The prepared SELECT statement query to run. Although it will accept both named and unnamed placeholders, named placeholders are strongly preferred as they are more self-documenting.

array $args: An array of values to substitute into the query. If the query uses named placeholders, this is an associative array in any order. If the query uses unnamed placeholders (?), this is an indexed array and the order must match the order of placeholders in the query string.

array $options: An array of options to control how the query operates.

Return value

string The name of the temporary table.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container and call queryTemporary() on it. For example, $injected_database->queryTemporary($query, $args, $options);

See also

https://www.drupal.org/node/2993033

\Drupal\Core\Database\Connection::queryTemporary()

\Drupal\Core\Database\Connection::defaultOptions()

Related topics

1 call to db_query_temporary()
DatabaseLegacyTest::testDbQueryTemporary in core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php
Tests deprecation of the db_query_temporary() function.

File

core/includes/database.inc, line 127
Core systems for the database layer.

Code

function db_query_temporary($query, array $args = [], array $options = []) {
  @trigger_error('db_query_temporary() is deprecated in drupal:8.0.0. It will be removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container and call queryTemporary() on it. For example, $injected_database->queryTemporary($query, $args, $options). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
  return Database::getConnection(_db_get_target($options))
    ->queryTemporary($query, $args, $options);
}