orderByHeader example



    $query = $this->connection->select('forum_index', 'f')
      ->extend(PagerSelectExtender::class)
      ->extend(TableSortExtender::class);
    $query->fields('f');
    $query
      ->condition('f.tid', $tid)
      ->addTag('node_access')
      ->addMetaData('base_table', 'forum_index')
      ->orderBy('f.sticky', 'DESC')
      ->orderByHeader($header)
      ->limit($forum_per_page);

    $count_query = $this->connection->select('forum_index', 'f');
    $count_query->condition('f.tid', $tid);
    $count_query->addExpression('COUNT(*)');
    $count_query->addTag('node_access');
    $count_query->addMetaData('base_table', 'forum_index');

    $query->setCountQuery($count_query);
    $result = $query->execute();
    $nids = [];
    
'pid' => ['data' => t('Person ID'), 'field' => 'pid'],
      'task' => ['data' => t('Task'), 'field' => 'task'],
      'priority' => ['data' => t('Priority'), 'field' => 'priority'],
    ];

    $query = $this->connection->select('test_task', 't');
    $query
      ->fields('t', ['tid', 'pid', 'task', 'priority']);

    $query = $query
      ->extend(TableSortExtender::class)
      ->orderByHeader($header);

    // We need all the results at once to check the sort.     $tasks = $query->execute()->fetchAll();

    return new JsonResponse([
      'tasks' => $tasks,
    ]);
  }

  /** * Runs a tablesort query with a second order_by after and returns the results. * * This function does care about the page GET parameter, as set by the * test HTTP call. * * @return \Symfony\Component\HttpFoundation\JsonResponse */
$query->condition('u.default_langcode', 1);

    $count_query = clone $query;
    $count_query->addExpression('COUNT([u].[uid])');

    $query = $query
      ->extend(PagerSelectExtender::class)
      ->extend(TableSortExtender::class);
    $query
      ->fields('u', ['uid'])
      ->limit(50)
      ->orderByHeader($header)
      ->setCountQuery($count_query);
    $uids = $query
      ->execute()
      ->fetchCol();

    $options = [];

    foreach (User::loadMultiple($uids) as $account) {
      $options[$account->id()] = [
        'title' => ['data' => ['#title' => $account->getAccountName()]],
        'username' => $account->getAccountName(),
        
'message',
      'variables',
      'link',
    ]);
    $query->leftJoin('users_field_data', 'ufd', '[w].[uid] = [ufd].[uid]');

    if (!empty($filter['where'])) {
      $query->where($filter['where']$filter['args']);
    }
    $result = $query
      ->limit(50)
      ->orderByHeader($header)
      ->execute();

    foreach ($result as $dblog) {
      $message = $this->formatMessage($dblog);
      if ($message && isset($dblog->wid)) {
        $title = Unicode::truncate(Html::decodeEntities(strip_tags($message)), 256, TRUE, TRUE);
        $log_text = Unicode::truncate($title, 56, TRUE, TRUE);
        // The link generator will escape any unsafe HTML entities in the final         // text.         $message = Link::fromTextAndUrl($log_textnew Url('dblog.event', ['event_id' => $dblog->wid][
          'attributes' => [
            
Home | Imprint | This part of the site doesn't use cookies.