@param null|string $alias

@return \Doctrine\DBAL\Connection

@throws \InvalidArgumentException if "connection"/"connections" or the identifier (alias) are not defined

@api
967065
public function getDbConnection(string $alias = null): \Doctrine\DBAL\Connection
    {
        if ($alias === null) {
            return $this->getContainer()->offsetGet('connection');
        }
        return $this->getContainer()->offsetGet('connections')[$alias];
    }
51637
public function query($table = null, $alias = null)
    {
        return $this->_di->get('ManaPHP\Db\Query', [$this])->from($table, $alias);
    }
353312
public function setAlias($alias)
    {
        $aliasManipulator = new AliasManipulator($this->originalDir, $this->alias);
        $aliasManipulator->setAlias($alias);

        return $aliasManipulator;
    }
1007300
public function getTableForAlias($alias)
    {
        if (isset($this->aliases[$alias])) {
            return $this->aliases[$alias];
        }

        return null;
    }
1154300
public function getAliasNamespace($alias)
    {
        foreach ($this->getManagerNames() as $name) {
            try {
                return $this->getManager($name)->getConfiguration()->getEntityNamespace($alias);
            } catch (ORMException $e) {
            }
        }

        throw ORMException::unknownEntityNamespace($alias);
    }
409580
public function getAdminConnection($name = null)
    {
        if (null === $name) {
            $name = $this->getDefaultConnectionName();
        }

        $serviceName = sprintf('doctrine_phpcr.admin.%s_session', $name);

        $connections = $this->getConnectionNames();
        if (!isset($connections[$name])) {
            throw new \InvalidArgumentException(sprintf('Doctrine %s Connection named "%s" does not exist.', $this->getName(), $name));
        }

        return $this->getService($serviceName);
    }
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;
    }
1169109
public function add(ClassInterface $import, $alias = NULL) {
    if (empty($alias)) {
      $alias = $import->getName();
    }

    if (empty($alias)) {
      throw new InvalidArgumentException('GClass: '.$import.' must have a valid FQN: '.$import->getFQN());
    }
    
    if (array_key_exists($lowerAlias = mb_strtolower($alias), $this->aliases)) {
      $usedBy = $this->classes[ $this->aliases[$lowerAlias] ];

      if (!$import->equals($usedBy)) {
        throw new LogicException('Alias: '.$alias.' is already used by Class '.$usedBy);
      }
    }
    
    $this->classes[$alias] = $import;
    $this->aliases[$lowerAlias] = $alias;
    return $this;
  }
1244140
public function load(string $alias): ?bool
    {
        if (\strpos($alias, self::FACADE_NAMESPACE) === 0) {
            return $this->loadFacade($alias);
        }

        if (isset($this->aliases[$alias])) {
            return \class_alias($this->aliases[$alias], $alias);
        }

        return null;
    }
918254
public function createResultSetMappingBuilder($alias)
    {
        $rsm = new ResultSetMappingBuilder($this->_em, ResultSetMappingBuilder::COLUMN_RENAMING_INCREMENT);
        $rsm->addRootEntityFromClassMetadata($this->_entityName, $alias);

        return $rsm;
    }
200897
public function make($alias, $use_singletons=false)
	{
		$alias = strtolower($alias);

		if (! array_key_exists($alias, $this->services))
		{
			throw new \InvalidArgumentException('No Service is registered for alias: '. $alias);
		}

		// The provider could be either a string (namespaced class)
		// or a Closure that returns an instance of the desired class.
		$service = $this->services[$alias];

		if (is_string($service))
		{
			if (! class_exists($service, true))
			{
				throw new \RuntimeException('Unable to locate the Service Provider: '. $this->services[$alias] );
			}

			return $this->inject($service, $use_singletons);
		}

		else if (is_callable($service))
		{
			return $service( $this );
		}

		return null;
	}
727676
public function alias($alias = null)
    {
        if ($alias === null) {
            return $this->_alias;
        }
        $this->_alias = $alias;

        return $this;
    }
1351111
public function getInstance($alias = null)
    {
        if (!$alias && !$this->mainAlias) {
            $namespace = explode('\\', $this->_entityName);
            $alias = strtolower(end($namespace));
            $this->mainAlias = $alias;
        } elseif ($alias) {
            $this->mainAlias = $alias;
        }

        return $this->qb ? $this->qb : $this->qb = $this->createQueryBuilder($this->mainAlias);
    }
95086
public function from($table, $alias = null)
    {
        $this->from['table'] = $table;
        $this->from['alias'] = $alias;

        return $this;
    }
510964
public function getFieldByAlias($alias)
    {
        foreach ($this->_fields as $column => $fields)
        {
            foreach ($fields as $field)
            {
                if ($field->getAlias() === $alias)
                {
                    return $field;
                }
            }
        }
        return null;
    }
1281430
private function getRelatedBuilder($alias) {
        foreach($this->getRelatedBuilders() as $key => $builder) {
            if($alias == $key) {
                return $builder;
            }
        }
        return null;
    }
563857
public function getMappingByAlias(string $alias) : Mapping
    {
        foreach ($this->mappings as $mapping) {
            if (0 === strcasecmp($alias, $mapping->getClassAlias())) {
                return $mapping;
            }
        }

        return Mapping::null();
    }