You are here

public function DatabaseTestController::dbQueryTemporary in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php \Drupal\database_test\Controller\DatabaseTestController::dbQueryTemporary()

Runs db_query_temporary() and outputs the table name and its number of rows.

We need to test that the table created is temporary, so we run it here, in a separate menu callback request; After this request is done, the temporary table should automatically dropped.

Return value

\Symfony\Component\HttpFoundation\JsonResponse

1 string reference to 'DatabaseTestController::dbQueryTemporary'
database_test.routing.yml in core/modules/system/tests/modules/database_test/database_test.routing.yml
core/modules/system/tests/modules/database_test/database_test.routing.yml

File

core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php, line 26
Contains \Drupal\database_test\Controller\DatabaseTestController.

Class

DatabaseTestController
Controller routines for database_test routes.

Namespace

Drupal\database_test\Controller

Code

public function dbQueryTemporary() {
  $table_name = db_query_temporary('SELECT age FROM {test}', array());
  return new JsonResponse(array(
    'table_name' => $table_name,
    'row_count' => db_select($table_name)
      ->countQuery()
      ->execute()
      ->fetchField(),
  ));
}