Select::preExecute

public Select::preExecute(SelectInterface $query = NULL)

Generic preparation and validation for a SELECT query.

Return value

TRUE if the validation was successful, FALSE if not.

Overrides SelectInterface::preExecute

File

core/lib/Drupal/Core/Database/Query/Select.php, line 446

Class

Select
Query builder for SELECT statements.

Namespace

Drupal\Core\Database\Query

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public function preExecute(SelectInterface $query = NULL) {
  // If no query object is passed in, use $this.
  if (!isset($query)) {
    $query = $this;
  }
 
  // Only execute this once.
  if ($query->isPrepared()) {
    return TRUE;
  }
 
  // Modules may alter all queries or only those having a particular tag.
  if (isset($this->alterTags)) {
    $hooks = array('query');
    foreach ($this->alterTags as $tag => $value) {
      $hooks[] = 'query_' . $tag;
    }
    \Drupal::moduleHandler()->alter($hooks, $query);
  }
 
  $this->prepared = TRUE;
 
  // Now also prepare any sub-queries.
  foreach ($this->tables as $table) {
    if ($table['table'] instanceof SelectInterface) {
      $table['table']->preExecute();
    }
  }
 
  foreach ($this->union as $union) {
    $union['query']->preExecute();
  }
 
  return $this->prepared;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.