Build the lit of tables.
@param  boolean $with_alias  Add aliases or not.
@return string
333544
protected function buildTables($with_alias=true) {
		$tables = [];
		$params = [];
		if(!$this->tables)
			throw new \Exception('Must set tables with method from($tables) before running the query.');
		foreach($this->tables as $alias=>$table) {
			if($table instanceof static) {
				$tables[] = '('.$table->buildSQL().') '.$this->quote.$alias.$this->quote;
				$params = array_merge($params, $table->getParameters());
			}
			elseif($table instanceof Raw) {
				$tables[] = '('.$table->getSQL().') '.$this->quote.$alias.$this->quote;
				$params = array_merge($params, $table->getParameters());
			}
			elseif($alias !== $table && $with_alias)
				$tables[] = $this->quote.$table.$this->quote.' '.$this->quote.$alias.$this->quote;
			else
				$tables[] = $this->quote.$table.$this->quote;
		}
		$sql = implode(', ', $tables);
		return [$sql, $params];
	}
64725
private function buildFrom()
	{
		$froms = [];

		foreach ($this->from as $from)
		{
			$string = $this->connection->quoteName($from['table']);

			// See if we're including an alias
			if (isset($from['as']))
			{
				$string .= ' AS ' . $this->connection->quoteName($from['as']);
			}

			$froms[] = $string;
		}

		return 'FROM ' . implode(',', $froms);
	}
195459
public function createQueryBuilder($alias = null)
    {
        if ($alias === null) {
            $alias = $this->getAlias();
        }

        if (empty($alias)) {
            $select = '*';
        } else {
            $select = $alias . '.*';
        }

        return $this->em->createQueryBuilder()
            ->select($select)
            ->from($this->getTableName(), $alias);
    }
408633
public function ___build(): string
    {
        $tables = \implode(', ', $this->from);
        $where = $limit = '';

        if ($this->where !== '') {
            $where = \sprintf(' WHERE %s', $this->where);
        }
        if ($this->limit !== 0) {
            $limit = \sprintf(' LIMIT %s', $this->limit);
        }

        return \sprintf('DELETE FROM %s%s%s', $tables, $where, $limit);
    }
333681
public function table($table, /*# string */ $alias = '')
    {
        $tbl = $this->fixTable($table, $alias);
        $clone = [] === $this->tables ? $this : clone $this;
        $clone->tables = $tbl;
        return $clone;
    }
192678
public function getIdColumnName(bool $withTableName = false): string
    {
        return ($withTableName) ? $this->addTableName($this->idColumnName) : $this->idColumnName;
    }
137436
static function &aliasTable()
    {
        $aliasTable =& $GLOBALS['eZCharsetInfoTable'];
        if ( !is_array( $aliasTable ) )
        {
            $aliasTable = array( 'ascii' => 'us-ascii',
                                 'latin1' => 'iso-8859-1',
                                 'latin2' => 'iso-8859-2',
                                 'latin3' => 'iso-8859-3',
                                 'latin4' => 'iso-8859-4',
                                 'latin5' => 'iso-8859-9',
                                 'latin6' => 'iso-8859-10',
                                 'latin7' => 'iso-8859-13',
                                 'latin8' => 'iso-8859-14',
                                 'latin9' => 'iso-8859-15',
                                 'cyrillic' => 'iso-8859-5',
                                 'arabic' => 'iso-8859-6',
                                 'greek' => 'iso-8859-7',
                                 'hebrew' => 'iso-8859-8',
                                 'thai' => 'iso-8859-11',

                                 'koi8-r' => 'koi8-r',
                                 'koi-8-r' => 'koi8-r',
                                 'koi8r' => 'koi8-r',

                                 'koi8-u' => 'koi8-u',
                                 'koi-8-u' => 'koi8-u',
                                 'koi8u' => 'koi8-u',

                                 'cp1250' => 'windows-1250',
                                 'cp1251' => 'windows-1251',
                                 'cp1252' => 'windows-1252',
                                 'cp1253' => 'windows-1253',
                                 'cp1254' => 'windows-1254',
                                 'cp1255' => 'windows-1255',
                                 'cp1256' => 'windows-1256',
                                 'cp1257' => 'windows-1257',
                                 'cp1258' => 'windows-1258',
                                 'winlatin1' => 'windows-1252',
                                 'winlatin2' => 'windows-1250',
                                 'wincyrillic' => 'windows-1251',
                                 'wingreek' => 'windows-1253',
                                 'winturkish' => 'windows-1254',
                                 'winhebrew' => 'windows-1255',
                                 'winarabic' => 'windows-1256',
                                 'winbaltic' => 'windows-1257',
                                 'winvietnamese' => 'windows-1258',

                                 'doslatinus' => 'cp437',
                                 'dosgreek' => 'cp737',
                                 'dosbaltrim' => 'cp775',
                                 'doslatin1' => 'cp850',
                                 'doslatin2' => 'cp852',
                                 'doscyrillic' => 'cp855',
                                 'dosturkish' => 'cp857',
                                 'dosportuguese' => 'cp860',
                                 'dosicelandic' => 'cp861',
                                 'doshebrew' => 'cp862',
                                 'doscanadaf' => 'cp863',
                                 'dosarabic' => 'cp864',
                                 'dosnordic' => 'cp865',
                                 'dosgreek2' => 'cp869',
                                 'doscyrillicrussian' => 'cp866',
                                 'dosthai' => 'cp874',

                                 'macroman' => 'macintosh',
                                 'nextstep' => 'next',

                                 'utf8' => 'utf-8',
                                 'utf7' => 'utf-7',

                                 'utf16' => 'utf-16',
                                 'utf16be' => 'utf-16be',
                                 'utf16le' => 'utf-16le',

                                 'utf32' => 'utf-32',
                                 'utf32be' => 'utf-32be',
                                 'utf32le' => 'utf-32le',

                                 'ucs4' => 'ucs-4',
                                 'ucs4be' => 'ucs-4be',
                                 'ucs4le' => 'ucs-4le',

                                 'ucs2' => 'ucs-2',
                                 'ucs2be' => 'ucs-2be',
                                 'ucs2le' => 'ucs-2le',

                                 'shift-jis' => 'cp932',
                                 'gbk' => 'gbk',
                                 'euc-cn' => 'euc-cn',
                                 'unifiedhangul' => 'cp849',
                                 'uhc' => 'cp849',
                                 'big5' => 'cp850'
                                 );
            for ( $i = 1; $i <= 15; ++$i )
            {
                $aliasTable["iso8859-$i"] = "iso-8859-$i";
                $aliasTable["iso8859$i"] = "iso-8859-$i";
            }
            $aliasTable['unicode'] = 'unicode';
        }
        return $aliasTable;
    }
964143
public function hasColumnAlias($alias)
    {
        return $this->hasAlias($alias) && $this->getExpression($this->getHash($alias)) instanceof Expr\Column;
    }
891748
public function getLeftColumnName(bool $withTableName = false): string
    {
        return ($withTableName) ? $this->addTableName($this->leftColumnName) : $this->leftColumnName;
    }
1191299
public function From(string $table, string $alias = ''): QueryBuilder
    {
        $this->table = $table;
        
        if (! empty($alias)) {
            $this->alias = $alias;
        }
        
        return $this;
    }
930555
public function join($trueTableName, $alias, $on) {
        $join = new Join($trueTableName, $alias, $on);

        $this->statementContext->getJoinClause()->addJoin($join);
        return $this;
    }
916456
private function getJoinSql($baseTableAlias)
    {
        $joinSql           = '';
        $identifierColumns = $this->class->getIdentifierColumns($this->em);

        // INNER JOIN parent tables
        $parentClass = $this->class;

        while (($parentClass = $parentClass->getParent()) !== null) {
            $conditions = [];
            $tableName  = $parentClass->table->getQuotedQualifiedName($this->platform);
            $tableAlias = $this->getSQLTableAlias($parentClass->getTableName());
            $joinSql   .= ' INNER JOIN ' . $tableName . ' ' . $tableAlias . ' ON ';

            foreach ($identifierColumns as $idColumn) {
                $quotedColumnName = $this->platform->quoteIdentifier($idColumn->getColumnName());

                $conditions[] = $baseTableAlias . '.' . $quotedColumnName . ' = ' . $tableAlias . '.' . $quotedColumnName;
            }

            $joinSql .= implode(' AND ', $conditions);
        }

        // OUTER JOIN sub tables
        foreach ($this->class->getSubClasses() as $subClassName) {
            $conditions = [];
            $subClass   = $this->em->getClassMetadata($subClassName);
            $tableName  = $subClass->table->getQuotedQualifiedName($this->platform);
            $tableAlias = $this->getSQLTableAlias($subClass->getTableName());
            $joinSql   .= ' LEFT JOIN ' . $tableName . ' ' . $tableAlias . ' ON ';

            foreach ($identifierColumns as $idColumn) {
                $quotedColumnName = $this->platform->quoteIdentifier($idColumn->getColumnName());

                $conditions[] = $baseTableAlias . '.' . $quotedColumnName . ' = ' . $tableAlias . '.' . $quotedColumnName;
            }

            $joinSql .= implode(' AND ', $conditions);
        }

        return $joinSql;
    }
770515
public function ___build(): string
    {
        $tables = \implode(', ', $this->tables);
        $fields = \implode(', ', $this->fields);
        $where = $orderBy = $limit = '';

        if ($this->where != '') {
            $where = \sprintf(' WHERE %s', $this->where);
        }
        if (\count($this->orderBy) > 0) {
            $orderBy = \sprintf(' ORDER BY %s', \implode(', ', $this->orderBy));
        }
        if ($this->limit != 0) {
            $limit = \sprintf(' LIMIT %s', $this->limit);
        }

        return \sprintf('UPDATE %s SET %s%s%s%s', $tables, $fields, $where, $orderBy, $limit);
    }
1022826
protected function getFirstTableAlias(
        /*# string */ $left
    )/*# : string */ {
        if (false !== strpos($left, '.')) { // alias exists
            return '';
        } else { // prepend first table alias
            $tables = &$this->getClause('TABLE');
            reset($tables);
            $alias = key($tables);
            return (is_int($alias) ? $tables[$alias][0] : $alias) . '.';
        }
    }
1224278
public function join($tableName, $alias = null)
    {
        $this->joins[] = ' LEFT JOIN ?f as ?f';
        $this->lastJoinAlias = $alias;
        $this->joinArguments[] = $tableName;
        $this->joinArguments[] = $alias;
        return $this;
    }
352200
public function findChildByAlias($alias)
    {
		$id = self::getDbConnection()->fetchColumn("select A.id from dir_data A, dir_structure B, dir_structure C where C.data_id=? and B.data_id=A.id and B.lft BETWEEN C.lft and C.rght and A.tablename=?", array($this->id, $alias));
        if ($id) {
            return Catalog::getById($id);
        } else return FALSE;
    }
1072981
public function getAlias()
    {
        if ($this->_alias === null) {
            $alias = namespaceSplit(get_class($this));
            $alias = substr(end($alias), 0, -5) ?: $this->_table;
            $this->_alias = $alias;
        }

        return $this->_alias;
    }