function DatabaseTestController::pagerQueryOdd

Same name in other branches
  1. 9 core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php \Drupal\database_test\Controller\DatabaseTestController::pagerQueryOdd()
  2. 8.9.x core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php \Drupal\database_test\Controller\DatabaseTestController::pagerQueryOdd()
  3. 10 core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php \Drupal\database_test\Controller\DatabaseTestController::pagerQueryOdd()

Runs a pager query and returns the results.

This function does care about the page GET parameter, as set by the test HTTP call.

Return value

\Symfony\Component\HttpFoundation\JsonResponse

1 string reference to 'DatabaseTestController::pagerQueryOdd'
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 79

Class

DatabaseTestController
Controller routines for database_test routes.

Namespace

Drupal\database_test\Controller

Code

public function pagerQueryOdd($limit) {
    $query = $this->connection
        ->select('test_task', 't');
    $query->fields('t', [
        'task',
    ])
        ->orderBy('pid');
    // This should result in 4 pages of results.
    $query = $query->extend(PagerSelectExtender::class)
        ->limit($limit);
    $names = $query->execute()
        ->fetchCol();
    return new JsonResponse([
        'names' => $names,
    ]);
}

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