public function getConnection()
    {
        if (!$this->_connection) {

            $options = array(
                    // server endpoint to connect to
                    ConnectionOptions::OPTION_ENDPOINT       => $this->_endpoint,
                    // authorization type to use (currently supported: 'Basic')
                    ConnectionOptions::OPTION_AUTH_TYPE      => 'Basic',
                    // user for basic authorization
                    ConnectionOptions::OPTION_AUTH_USER      => $this->_username,
                    // password for basic authorization
                    ConnectionOptions::OPTION_AUTH_PASSWD    => $this->_password,
                    ConnectionOptions::OPTION_TRACE          => $this->_debug,
                    ConnectionOptions::OPTION_ENHANCED_TRACE => true,
                    ConnectionOptions::OPTION_DATABASE       => $this->_database
            );

            $this->_connection = new Connection($options);
        }

        return $this->_connection;
    }