Get table name with alias

@param $query is used for quoting. It can be Flupdo or FlupdoBuilder
@return quoted SQL fragment containing table name, i.e. "`table` AS `this`".
322539
protected function queryGetThisTable($query)
	{
		if ($this->table_alias) {
			return $query->quoteIdent($this->table).' AS '.$query->quoteIdent($this->table_alias);
		} else {
			return $query->quoteIdent($this->table);
		}
	}
313482
public function aliasedColumn($query, $columnName, $tableName = null)
    {
        return $this->alias(
            $this->quoteColumn($columnName, $tableName),
            $this->quoteIdentifier(
                ($tableName ? $tableName . '_' : '') .
                $columnName
            )
        );
    }
51637
public function query($table = null, $alias = null)
    {
        return $this->_di->get('ManaPHP\Db\Query', [$this])->from($table, $alias);
    }
1324264
public function build(AbstractQuery $query, Schema &$schema) {
		$from = '';
		
		//obtain table/alias from query
		$table = $query->getTable();
		$alias = $query->getAlias();
		
		if (isset($alias))
			$from .= '@@' . $table . ' ' . $alias . ' ';
		else
			$from .= '@@' . $table . ' ';
		
		//add joins
		$joins = $query->getJoins();
		foreach ($joins as $join)
			$from .= $this->translateJoin($join, $schema);
		
		return $from;
	}
1249301
public function table($table = null, $alias = null)
    {
        $query = new Table($this); return $query->table($table, $alias);
    }
1026726
public function scopeMeta($query, $alias = null)
    {
        $alias = (empty($alias)) ? $this->getMetaTable() : $alias;
        return $query->join($this->getMetaTable() . ' AS ' . $alias, $this->getQualifiedKeyName(), '=', $alias . '.' . $this->getMetaKeyName())->select($this->getTable() . '.*');
    }
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;
    }
160178
public function findAll($query = null) {
        if ($query === null) {
            $mapping = $this->getMapping();
            $table = $this->escapeIdentifier($mapping['table']);
            $query = 'select * from '.$table;
        }
        return $this->getWorker()->findAll($query);
    }
1062602
public function sqlFrom()
    {
        if (!$this->hasTable()) {
            throw new UnexpectedValueException(
                'Can not get SQL FROM clause. No table defined.'
            );
        }

        $table = $this->table();
        return '`'.$table.'` AS `'.self::DEFAULT_TABLE_ALIAS.'`';
    }
831101
public function query($query)
    {
        // Replace prefix placeholder with prefix
        $query = str_replace("{prefix}", $this->prefix, $query);

        // Log last query and query count
        $this->lastQuery = $query;
        $this->queryCount++;

        // Query database
        return $this->connection->query($query);
    }
823509
public function generateAlias(Clause $clause)
    {
        if ($clause instanceof FieldName)
        {
            $table = $clause->getTable();
            if (empty($table))
            {
                // When no table is defined, it means only one table is being
                // used in the query. Aliases will not be required
                return "";
            }

            $prefix = $table->getPrefix();
            $alias = $prefix . '_' . $clause->getField();
        }
        elseif ($clause instanceof SQLFunction)
        {
            $func = $clause->getFunction();
            $alias = strtolower($func);
        }
        else
            throw new ImplementationException("No alias generation implemented for: " . get_class($clause));

        $cnt = 1;
        $base_alias = $alias;
        while (isset($this->field_aliases[$alias]))
            $alias = $base_alias . (++$cnt);

        $this->field_aliases[$alias] = true;
        return $alias;
    }
156751
protected function wantsTemporary($query)
    {
        foreach ($query->getWhere() as $whereClause) {
            $from = array_values($query->getFrom());
            // SQLQuery will automatically add double quotes and single quotes to values, so check against that.
            $key = key($whereClause);
            if ($key == "{$from[0]}.\"MultiFormIsTemporary\" = ?" && current($whereClause[$key]) == 1) {
                return true;
            }
        }

        return false;
    }
609955
public function scopeStillActive($query)
    {
        $query->where(function ($query) {
            return $query->where('start_at', '<=', Carbon::now())->orWhereNull('start_at');
        })
        ->where(function ($query) {
            return $query->where('end_at', '>=', Carbon::now())->orWhereNull('end_at');
        })
        ->where(function ($query) {
            return $query->where('parent_id', 0)->orWhereNull('parent_id');
        });

        return $query;
    }
81685
public function build(&$query)
    {
        $segments = array();

        if (isset($query['oid'])) {
            $segments[] = '@'.$query['oid'];
        }

        if (isset($query['q'])) {
            $segments[] = $query['q'];
        }

        //we don't need the view
        unset($query['view']);
        unset($query['oid']);
        unset($query['q']);

        return $segments;
    }
1193696
public static function table(string $tableName, string $alias = null): QueryBuilder
    {
        $query = new QueryBuilder();
        $query = $query->table($tableName, $alias);

        return $query;
    }
54027
public function getSqlName(string $table, string $name): string
    {
        return $table . '_' . $this->getType() . '_' . $name;
    }
244137
public function alias($alias)
    {
        if (is_array($alias)) {
            foreach ($alias as $key => $val) {
                $this->options['alias'][$key] = $val;
            }
        } else {
            if (isset($this->options['table'])) {
                $table = is_array($this->options['table']) ? key($this->options['table']) : $this->options['table'];
                if (false !== strpos($table, '__')) {
                    $table = $this->parseSqlTable($table);
                }
            } else {
                $table = $this->getTable();
            }

            $this->options['alias'][$table] = $alias;
        }
        return $this;
    }