Walks down a FromClause AST node, thereby generating the appropriate SQL.

@param string $fromClause

@return string the SQL
339797
public function walkFromClause($fromClause)
    {
        $sql = parent::walkFromClause($fromClause);
        $name = $this->getQuery()->getHint('acl.entityRootTableName');
        $alias = $this->getQuery()->getHint('acl.entityRootTableDqlAlias');
        $tableAlias = $this->getSQLTableAlias($name, $alias);
        $extraQuery = $this->getQuery()->getHint('acl.extra.query');

        $tempAclView = <<<tempAclView
JOIN ({$extraQuery}) ta_ ON {$tableAlias}.id = ta_.id
tempAclView;

        return $sql . ' ' . $tempAclView;
    }
365894
public function walkSelectStatement(\Doctrine\ORM\Query\AST\SelectStatement $AST)
    {
        $parent = null;
        $parentName = null;
        foreach ($this->_getQueryComponents() as $dqlAlias => $qComp) {
            if ($qComp['parent'] === null && $qComp['nestingLevel'] == 0) {
                $parent = $qComp;
                $parentName = $dqlAlias;
                break;
            }
        }

        $pathExpression = new PathExpression(
            PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $parentName,
            $parent['metadata']->getSingleIdentifierFieldName()
        );
        $pathExpression->type = PathExpression::TYPE_STATE_FIELD;

        $AST->selectClause->selectExpressions = [
            new \Doctrine\ORM\Query\AST\SelectExpression(
                new \Doctrine\ORM\Query\AST\AggregateExpression('count', $pathExpression, true), null
            )
        ];

        // ORDER BY is not needed, only increases query execution through unnecessary sorting.
        $AST->orderByClause = null;
    }
1026902
private function getQueryClause($query, $clause)
    {
        $queries = $query->getMust();

        if ($clause == self::QUERY_CONDITION_NOT) {
            $queries = $query->getMustNot();
        } elseif ($clause == self::QUERY_CONDITION_SHOULD) {
            $queries = $query->getShould();
        }

        return $queries;
    }
845486
public void appendTableNameAndAliasTo(SQLStatementBuilder fromClause) {
        appendTableNameTo(fromClause);
        fromClause.append(' ');
        fromClause.append(mAlias);
    }
625181
public function walkSelectStatement(SelectStatement $AST)
    {
        if ($AST->havingClause) {
            throw new RuntimeException('Cannot count query that uses a HAVING clause. Use the output walkers for pagination');
        }

        $queryComponents = $this->getQueryComponents();
        // Get the root entity and alias from the AST fromClause
        $from = $AST->fromClause->identificationVariableDeclarations;

        if (count($from) > 1) {
            throw new RuntimeException('Cannot count query which selects two FROM components, cannot make distinction');
        }

        $fromRoot  = reset($from);
        $rootAlias = $fromRoot->rangeVariableDeclaration->aliasIdentificationVariable;
        $rootClass = $queryComponents[$rootAlias]['metadata'];
        $property  = $rootClass->getProperty($rootClass->getSingleIdentifierFieldName());
        $pathType  = PathExpression::TYPE_STATE_FIELD;

        if ($property instanceof AssociationMetadata) {
            $pathType = $property instanceof ToOneAssociationMetadata
                ? PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION
                : PathExpression::TYPE_COLLECTION_VALUED_ASSOCIATION;
        }

        $pathExpression = new PathExpression(
            PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION,
            $rootAlias,
            $property->getName()
        );

        $pathExpression->type = $pathType;

        $distinct = $this->getQuery()->getHint(self::HINT_DISTINCT);

        $AST->selectClause->selectExpressions = [new SelectExpression(
            new AggregateExpression('count', $pathExpression, $distinct),
            null
        ),
        ];

        // ORDER BY is not needed, only increases query execution through unnecessary sorting.
        $AST->orderByClause = null;
    }
559187
public function getDeleteFromClause($criteria, $tableName)
    {
        $sql = 'DELETE ';
        if ($queryComment = $criteria->getComment()) {
            $sql .= '/* ' . $queryComment . ' */ ';
        }
        if ($realTableName = $criteria->getTableForAlias($tableName)) {
            if ($this->useQuoteIdentifier()) {
                $realTableName = $this->quoteIdentifierTable($realTableName);
            }
            $sql .= $tableName . ' FROM ' . $realTableName . ' AS ' . $tableName;
        } else {
            if ($this->useQuoteIdentifier()) {
                $tableName = $this->quoteIdentifierTable($tableName);
            }
            $sql .= 'FROM ' . $tableName;
        }

        return $sql;
    }
125295
private function getUpdateQuery()
    {
        if (isset($this->parts['from'][0]['alias'])) {
            $fromClause = $this->parts['from'][0]['alias'].' FROM '.$this->getFromClause();
        } else {
            $fromClause = $this->parts['from'][0]['table'];
        }

        $setClause = array();

        foreach ($this->parts['set'] as $idenfier => $value) {
            $setClause[] = $this->getExpressionBuilder()->equal($idenfier, $value);
        }

        return 'UPDATE '.$fromClause.
               ' SET '.implode(', ', $setClause).
               (($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null);
    }
389979
protected function fixOnClause($onClause)
    {
        if (is_string($onClause)) {
            return [$onClause, '=', $onClause];
        } elseif (is_array($onClause) && !isset($onClause[2])) {
            return [$onClause[0], '=', $onClause[1]];
        } else {
            return $onClause;
        }
    }
1304392
@Override
    public String generateClause() {
        StringBuilder wherePart = new StringBuilder();
        wherePart.append(referenceIndices.generateColumnReference(columnSpec));
        if (not) {
            wherePart.append(" NOT");
        }
        wherePart.append(" IN (");
        for (int k = 0; k < elements.length; k++) {
            Object val = elements[k];
            wherePart.append(SqlGeneratorUtil.prepareValue(val));
            if (k + 1 < elements.length) {
                if ((k + 1) % 1000 == 0) {
                    wherePart.append(") OR ");
                    wherePart.append(referenceIndices.generateColumnReference(columnSpec));
                    wherePart.append(" IN (");
                } else {
                    wherePart.append(',');
                }
            }
        }
        wherePart.append(')');
        
        return wherePart.toString();
    }
1247887
public function toString($schemas = [], $aliases = [])
    {
        $fields = $this->dialect()->names($this->_parts['fields']);
        $sql = 'SELECT' .
            $this->_buildFlags($this->_parts['flags']) .
            $this->_buildChunk($fields ?: '*') .
            $this->_buildClause('FROM', $this->dialect()->names($this->_parts['from'])) .
            $this->_buildJoins($schemas, $aliases) .
            $this->_buildClause('WHERE', $this->dialect()->conditions($this->_parts['where'], compact('schemas', 'aliases'))) .
            $this->_buildClause('GROUP BY', $this->_group()) .
            $this->_buildClause('HAVING', $this->dialect()->conditions($this->_parts['having'], compact('schemas', 'aliases'))) .
            $this->_buildOrder($aliases) .
            $this->_buildClause('LIMIT', $this->_parts['limit']);

        if ($this->_parts['lock']) {
            $sql .= $this->_buildFlag($this->_parts['lock'], $this->_parts['lock']) .
                    $this->_buildFlag('NOWAIT', $this->_parts['noWait']);
        }

        return $this->_alias ? "({$sql}) AS " . $this->dialect()->name($this->_alias) : $sql;
    }
86197
protected function getOrderByClause($conn = null) {
		$statement = new QueryStatement($conn);
		$orders = $this->orders;
		foreach ($orders as &$order) {
			$order_parts = explode(' ', $order);
			if (count($order_parts) == 1 || count($order_parts) == 2) {
				$statement->addIdentifier($order_parts[0]);
				$order_parts[0] = QueryStatement::IDENTIFIER;
			}
			$order = implode(' ', $order_parts);
		}
		$statement->string = "\nORDER BY " . implode(', ', $orders);
		return $statement;
	}
1210077
public function from()
    {
        $from = '';

        $numargs = func_num_args();

        if ($this->oosql_del_multiFlag) {


            if ($numargs < $this->oosql_del_numargs) {
                $msg = 'Columns and passed data do not match! ' . $this->sql();
                throw new \Exception($msg, 9810, null);
            }


        }

        $from .= ' FROM ';

        $from .= $this->oosql_table;

        if ($numargs > 0) {
            $from .= ', ';

            $arg_list = func_get_args();

            for ($i = 0; $i < $numargs; $i++) {
                if ($i !== 0 && $numargs > $i) {
                    $from .= ', ';
                }

                if ($arg_list[$i] instanceof oosql) {

                    $arg_list[$i]->alias();
                    $fields = $arg_list[$i]->getFields($arg_list[$i]->getTableAlias());

                    $this->sql(',' . implode(', ', $fields));
                    $from .= $arg_list[$i]->getSql() . ' AS ' . $arg_list[$i]->getTableAlias();
                } else {
                    $from .= $arg_list[$i];
                }
            }
        }

        $this->sql($from);

        $this->oosql_fromFlag = false;

        return $this;
    }
1118678
public function DeleteClause()
    {
        $this->match(Lexer::T_DELETE);

        if ($this->lexer->isNextToken(Lexer::T_FROM)) {
            $this->match(Lexer::T_FROM);
        }

        $token = $this->lexer->lookahead;
        $deleteClause = new AST\DeleteClause($this->AbstractSchemaName());

        if ($this->lexer->isNextToken(Lexer::T_AS)) {
            $this->match(Lexer::T_AS);
        }

        $aliasIdentificationVariable = $this->AliasIdentificationVariable();

        $deleteClause->aliasIdentificationVariable = $aliasIdentificationVariable;
        $class = $this->em->getClassMetadata($deleteClause->abstractSchemaName);

        // Building queryComponent
        $queryComponent = array(
            'metadata'     => $class,
            'parent'       => null,
            'relation'     => null,
            'map'          => null,
            'nestingLevel' => $this->nestingLevel,
            'token'        => $token,
        );

        $this->queryComponents[$aliasIdentificationVariable] = $queryComponent;

        return $deleteClause;
    }
213915
public function buildSubSelect(Table $fromTable) : Select
    {
        $subSelect = Select::from($fromTable);
        $subSelect->setAlias($this->generateUniqueAliasFor($fromTable->getName()));

        $subSelect->outerSelectAliases = $this->getTakenAliases();

        return $subSelect;
    }
76844
public function toString(?JoinClauseStrategy $join = null, bool $useClause = true): string
    {
        return $this->fromToString($join, $useClause);
    }
53168
private function rebuildOrderByClauseForOuterScope(OrderByClause $orderByClause)
    {
        $dqlAliasToSqlTableAliasMap
            = $searchPatterns
            = $replacements
            = $dqlAliasToClassMap
            = $selectListAdditions
            = $orderByItems
            = [];

        // Generate DQL alias -> SQL table alias mapping
        foreach(array_keys($this->rsm->aliasMap) as $dqlAlias) {
            $dqlAliasToClassMap[$dqlAlias] = $class = $this->queryComponents[$dqlAlias]['metadata'];
            $dqlAliasToSqlTableAliasMap[$dqlAlias] = $this->getSQLTableAlias($class->getTableName(), $dqlAlias);
        }

        // Pattern to find table path expressions in the order by clause
        $fieldSearchPattern = '/(?<![a-z0-9_])%s\.%s(?![a-z0-9_])/i';

        // Generate search patterns for each field's path expression in the order by clause
        foreach($this->rsm->fieldMappings as $fieldAlias => $fieldName) {
            $dqlAliasForFieldAlias = $this->rsm->columnOwnerMap[$fieldAlias];
            $class = $dqlAliasToClassMap[$dqlAliasForFieldAlias];

            // If the field is from a joined child table, we won't be ordering
            // on it.
            if (!isset($class->fieldMappings[$fieldName])) {
                continue;
            }

            $fieldMapping = $class->fieldMappings[$fieldName];

            // Get the proper column name as will appear in the select list
            $columnName = $this->quoteStrategy->getColumnName(
                $fieldName,
                $dqlAliasToClassMap[$dqlAliasForFieldAlias],
                $this->em->getConnection()->getDatabasePlatform()
            );

            // Get the SQL table alias for the entity and field
            $sqlTableAliasForFieldAlias = $dqlAliasToSqlTableAliasMap[$dqlAliasForFieldAlias];
            if (isset($fieldMapping['declared']) && $fieldMapping['declared'] !== $class->name) {
                // Field was declared in a parent class, so we need to get the proper SQL table alias
                // for the joined parent table.
                $otherClassMetadata = $this->em->getClassMetadata($fieldMapping['declared']);
                if (!$otherClassMetadata->isMappedSuperclass) {
                    $sqlTableAliasForFieldAlias = $this->getSQLTableAlias($otherClassMetadata->getTableName(), $dqlAliasForFieldAlias);
                }
            }

            // Compose search/replace patterns
            $searchPatterns[] = sprintf($fieldSearchPattern, $sqlTableAliasForFieldAlias, $columnName);
            $replacements[] = $fieldAlias;
        }

        foreach($orderByClause->orderByItems as $orderByItem) {
            // Walk order by item to get string representation of it
            $orderByItemString = $this->walkOrderByItem($orderByItem);

            // Replace path expressions in the order by clause with their column alias
            $orderByItemString = preg_replace($searchPatterns, $replacements, $orderByItemString);

            $orderByItems[] = $orderByItemString;
        }

        return $orderByItems;
    }
67976
public function from($query)
    {
        $clause = '';

        $resource = $query->getRepository()->getResources()->main();

        $query->from($resource->getName().' AS '.$this->_store->quoteName($resource->getAlias()));

        if (!empty($query->from)) {
            $clause = ' FROM '.implode(' , ', $query->from);
        }

        return $clause;
    }