function Sql::queueTable
Same name in other branches
- 9 core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::queueTable()
- 8.9.x core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::queueTable()
- 11.x core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::queueTable()
Add a table to the query without ensuring the path.
This is a pretty internal function to Views and addTable() or ensureTable() should be used instead of this one, unless you are absolutely sure this is what you want.
Parameters
$table: The name of the table to add. It needs to exist in the global table array.
$relationship: The primary table alias this table is related to. If not set, the primary table will be used.
\Drupal\views\Plugin\views\join\JoinPluginBase $join: In some join configurations this table may actually join back through a different method; this is most likely to be used when tracing a hierarchy path. (node->parent->parent2->parent3). This parameter will specify how this table joins if it is not the default.
$alias: A specific alias to use, rather than the default alias.
Return value
string The alias of the table; this alias can be used to access information about the table and should always be used to refer to the table when adding parts to the query. Or FALSE if the table was not able to be added.
3 calls to Sql::queueTable()
- Sql::addTable in core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php - Add a table to the query, ensuring the path exists.
- Sql::ensurePath in core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php - Ensures the given table can be linked to the primary table in the JOINs.
- Sql::ensureTable in core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php - Ensures a table exists in the queue.
File
-
core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php, line 491
Class
- Sql
- Views query plugin for an SQL query.
Namespace
Drupal\views\Plugin\views\queryCode
public function queueTable($table, $relationship = NULL, ?JoinPluginBase $join = NULL, $alias = NULL) {
// If the alias is set, make sure it doesn't already exist.
if (isset($this->tableQueue[$alias])) {
return $alias;
}
if (empty($relationship)) {
$relationship = $this->view->storage
->get('base_table');
}
if (!array_key_exists($relationship, $this->relationships)) {
return FALSE;
}
if (!$alias && $join && $relationship && !empty($join->adjusted) && $table != $join->table) {
if ($relationship == $this->view->storage
->get('base_table')) {
$alias = $table;
}
else {
$alias = $relationship . '_' . $table;
}
}
// Check this again to make sure we don't blow up existing aliases for already
// adjusted joins.
if (isset($this->tableQueue[$alias])) {
return $alias;
}
$alias = $this->markTable($table, $relationship, $alias);
// If no alias is specified, give it the default.
if (!isset($alias)) {
$alias = $this->tables[$relationship][$table]['alias'] . $this->tables[$relationship][$table]['count'];
}
// If this is a relationship based table, add a marker with
// the relationship as a primary table for the alias.
if ($table != $alias) {
$this->markTable($alias, $this->view->storage
->get('base_table'), $alias);
}
// If no join is specified, pull it from the table data.
if (!isset($join)) {
$join = $this->getJoinData($table, $this->relationships[$relationship]['base']);
if (empty($join)) {
return FALSE;
}
$join = $this->adjustJoin($join, $relationship);
}
$this->tableQueue[$alias] = [
'table' => $table,
'num' => $this->tables[$relationship][$table]['count'],
'alias' => $alias,
'join' => $join,
'relationship' => $relationship,
];
return $alias;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.