public function connection($config = null, $forceConnect = false)
    {

        if ($this->connection && !$forceConnect) {
            return $this->connection;
        }

        !isset($config) || $this->config($config);

        $ref = new \ReflectionClass($this->getHandler());

        try {
            /** @var \PDO $connection */
            $this->connection = $ref->newInstanceArgs([
                $this->getConnectionString(),
                $this->getUser(),
                $this->getPassword(),
                $this->getHandlerOptions()
            ]);
        } catch (\PDOException $e) {
            throw new DatabaseException($e->getMessage());
        }

        return $this->connection;
    }
public function connection($config = null, $forceConnect = false)
    {

        if ($this->connection && !$forceConnect) {
            return $this->connection;
        }

        !isset($config) || $this->config($config);

        $ref = new \ReflectionClass($this->getHandler());

        try {
            /** @var \PDO $connection */
            $this->connection = $ref->newInstanceArgs([
                $this->getConnectionString(),
                $this->getUser(),
                $this->getPassword(),
                $this->getHandlerOptions()
            ]);
        } catch (\PDOException $e) {
            throw new DatabaseException($e->getMessage());
        }

        return $this->connection;
    }
public function connection ( $ config = null , $ forceConnect = false ) { if ( $ this -> connection && ! $ forceConnect ) { return $ this -> connection ; } ! isset ( $ config ) || $ this -> config ( $ config ) ; $ ref = new \ ReflectionClass ( $ this -> getHandler ( ) ) ; try { /** @var \PDO $connection */ $ this -> connection = $ ref -> newInstanceArgs ( [ $ this -> getConnectionString ( ) , $ this -> getUser ( ) , $ this -> getPassword ( ) , $ this -> getHandlerOptions ( ) ] ) ; } catch ( \ PDOException $ e ) { throw new DatabaseException ( $ e -> getMessage ( ) ) ; } return $ this -> connection ; }
Returns a PDO connection

@param null $config
@param bool $forceConnect

@return \PDO
@throws DatabaseException
Returns a PDO connection