Get instance of connection

@param string $name connection identifier

@return Client

@throws Exception
356555
public function get($name)
    {
        // get from cache
        if (isset($this->pool[$name])) {
            return $this->pool[$name];
        }
        
        // check if connection exists
        if (!isset($this->configuration[$name])) {
            throw new Exception('Connection with name ' . $name . ' not found');
        }
        
        // check if dsn exists
        if (!isset($this->configuration[$name]['dsn'])) {
            $this->configuration[$name]['dsn'] = null;
        }
        
        // check if connect options exists
        if (empty($this->configuration[$name]['connectOptions'])) {
            $this->configuration[$name]['connectOptions'] = null;
        }
        
        // init client
        $client = new Client(
            $this->configuration[$name]['dsn'],
            $this->configuration[$name]['connectOptions']
        );
        
        if (isset($this->configuration[$name]['mapping'])) {
            $client->map($this->configuration[$name]['mapping']);
        }
        
        if (isset($this->configuration[$name]['defaultDatabase'])) {
            $client->useDatabase($this->configuration[$name]['defaultDatabase']);
        }
        
        $this->pool[$name] = $client;
        
        return $client;
    }
147253
protected function get($name)
    {
        if (isset($this->site[$name])) {
            return $this->site[$name];
        }

        throw new Exception("The property $name could not be found on the website ID " . (int)$this->id);
    }
169437
public function getConnection($name = null)
    {
        if ($name === null) {
            reset($this->config);
            $name = key($this->config);
        }

        if (!isset($this->config[$name])) {
            throw new \Exception('Configuration name does not exists !');
        }

        if (!isset($this->config[$name]['engine'])) {
            throw new \Exception('Engine not specified in configuration !');
        }

        $engine = $this->config[$name]['engine'];

        if (!isset($this->connections[$engine][$name])) {
            $method = 'get' . $engine;
            if (!method_exists($this, $method)) {
                throw new \Exception('Engine does not exists ! (engine: ' . $engine . ')');
            }

            $this->connections[$engine][$name] = $this->$method($name);
        }

        return $this->connections[$engine][$name];
    }
551710
public static function get_conn($name = 'default')
    {
        if (isset(self::$connections[$name])) {
            return self::$connections[$name];
        }

        // lazy connect
        $config = static::getConfig($name);
        if ($config) {
            return static::connect($config, $name);
        }

        return null;
    }
361111
public function getService($name)
    {
        try {
            if (!$this->isRegisteredService($name)) {
                $this->registerService($name);
            }
            return $this->di->get($name);
        } catch (\Phalcon\DI\Exception $ex) {
            throw new Exception($ex->getMessage().', using: '.$name);
        }
    }
748559
protected function get($name)
    {
        if ($this->modified === null) {
            $this->load();
        }

        if (false === array_key_exists($name, $this->properties)) {
            throw new Exception('Unknown property "' . $name . '"');
        }

        return $this->resolve($this->properties[$name], $name);
    }
9869
public function serverGetByName($name)
  {
    foreach($this->serverList() as $server)
    {
      if($server["virtualserver_name"] == $name) return $server;
    }

    throw new Exception("invalid serverID", 0x400);
  }
769333
public function into($name)
    {
        if (is_string($name) || is_array($name)) {
            return $this->connection($name);
        } else {
            return $this->connection(func_get_args());
        }
    }
55673
public function getClient($name = null)
    {
        if (null === $name) {
            $name = $this->defaultClientName;
        }

        if (in_array($name, $this->getClientNames())) {
            return $this->clients[$name];
        }

        throw new \InvalidArgumentException(($name === null ? 'default client' : 'client ' . $name) . ' not configured');
    }
687328
public static function getInstance($name = 'default')
    {
        if (isset(self::$instance[$name])) {
            return self::$instance[$name];
        }

        $config = Registry::get('config');
        $config = $config['redis'];
        if (!isset($config[$name], $config[$name]['host'])) {
            throw new ConfigException('No redis config!');
        }

        $config = $config[$name];
        $connectType = isset($config['pconnect']) && $config['pconnect'] ? 'pconnect' : 'connect';

        $redis = new self;
        if (!$redis->$connectType(
            $config['host'],
            isset($config['port']) ? $config['port'] : 6379,
            isset($config['timeout']) ? $config['timeout'] : 1
        )) {
            throw new RedisException('Redis server went away!');
        }

        if (isset($config['prefix'])) {
            $redis->setOption(Redis::OPT_PREFIX, $config['prefix']);
        }

        return self::$instance[$name] = $redis;
    }
745567
public function connection($name = 'default')
    {
        if ( ! isset($this) ) return self::getInstance()->clients[Config::get("redis.$name")];
        return $this->clients[ Config::get("redis.$name") ];
    }
513609
public function getClient(string $name = 'default')
    {
        if (!isset($this->clients[$name])) {
            throw new InvalidArgumentException("No client with name \"$name\"");
        }

        return $this->clients[$name];
    }
1149735
public function getConnection(string $name = null): Connection
    {
        if (is_null($name) and !is_null($this->defaultConnection)) {
            return $this->defaultConnection;
        }

        if (is_null($name) or !array_key_exists($name, $this->registry)) {
            throw new MongoDBConnectionNameNotFoundException($name);
        }

        return $this->registry[$name];
    }
317761
public function connection($name = 'default')
	{
		$this->curConnection = Arr::get($this->clients, $name ?  : 'default');
        return $this->curConnection;
	}
492117
public function connection($name = null)
    {
        $name = $name ?: 'default';

        if (isset($this->connections[$name])) {
            return $this->connections[$name];
        }

        return $this->connections[$name] = $this->configure(
            $this->resolve($name), $name
        );
    }
293972
public function connection($name = null)
    {
        if (is_null($name)) {
            $name = $this->getDefaultConnection();
        }

        if (! isset($this->connections[$name])) {
            throw new InvalidArgumentException("Connection [{$name}] is not registered.");
        }

        return $this->connections[$name];
    }
1111610
public function get(string $name)
    {
        if ($this->isSingleton($name)) {
            /*
             * Object is instantiated as
             * singleton already. Just fetch it.
             */
            return $this->singletonObjects[$name];
        } elseif ($this->isDefined($name)) {
            /*
             * Creates a new instance
             * using map information.
             */
            return $this->build($name);
        } elseif (class_exists($name)) {
            /*
             * Class exists but it is
             * not mapped yet.
             */
            $this->set(
                $name,
                method_exists($name, '__construct') ?
                    $this->generateArgumentsMap($name) : []
            );

            return $this->get($name);
        }

        throw new \Exception("Couldn't create '$name'");
    }