/* public abstract function connect($options);
960862
protected function reduceResult($result)
    {
        if (is_array($result) && (count($result) == 1)) {
            reset($result);
            return $this->reduceResult($result[key($result)]);
        } else {
            return $result;
        }
    }
629949
public function connection($username, $password, array $options)
    {
        if ($this->pdo)
        {
            throw new \BadFunctionCallException(__METHOD__);
        }

        $class     = $this->class;
        $this->pdo = new $class($this->dsn(), $username, $password, $options);

        return $this->pdo;
    }
607899
protected function init(array $options = array())
    {
        foreach ($options as $key => $value) {
            if (property_exists($this, $key)) {
                $this->{$key} = $value;
            }
        }
    }
1009503
public function getConnection(array $options = array()) {
        $conn =& $this->connection;
        $mutable = $this->getOption(xPDO::OPT_CONN_MUTABLE, $options, null);
        if (!($conn instanceof xPDOConnection) || ($mutable !== null && (($mutable == true && !$conn->isMutable()) || ($mutable == false && $conn->isMutable())))) {
            if (!empty($this->_connections)) {
                shuffle($this->_connections);
                $conn = reset($this->_connections);
                while ($conn) {
                    if ($mutable !== null && (($mutable == true && !$conn->isMutable()) || ($mutable == false && $conn->isMutable()))) {
                        $conn = next($this->_connections);
                        continue;
                    }
                    $this->connection =& $conn;
                    break;
                }
            } else {
                $this->log(xPDO::LOG_LEVEL_ERROR, "Could not get a valid xPDOConnection", '', __METHOD__, __FILE__, __LINE__);
            }
        }
        return $this->connection;
    }
606106
public function connect($type, $host, $dbname = '', $username = null, $password = null, array $options = array())
    {
        if ($this->PDO) {
            // If this object already has a PDO object, don't attempt a new connection
            return $this;
        }

        $dsn = '';

        if ($type == 'sqlite') {
            $dsn = "{$type}:{$host}";
        } else {
            $dsn = "{$type}:host={$host};dbname={$dbname}";
        }
        $PDO = new PDO($dsn, $username, $password, $options);

        if (!$PDO) {
            return false;
        }

        $this->PDO = $PDO;

        $this->setEscapeChar();
        return $this;
    }
22758
protected function addGlobalOptions($options)
    {
        if (!empty($options)) {
            foreach ($options as $name => $value) {
                $this->globalOptions[$name] = $value;
            }
        }
    }
360437
public static function GetConnection ($options) {
		$connection_name = static::AdjustConnectionName($options);
		$priority = static::AdjustPriority($options);
		$number = static::AdjustStackNumber($options);

		if (!isset(static::$_connectionList[$connection_name][$priority][$number])) {
			static::_Connect($options);
		}
		return static::$_connectionList[$connection_name][$priority][$number];
	}
114333
public function setUp($options = [])
    {
        parent::setUp($options);
        if (isset($options['changeid'])) {
            $this->changeid = $options['changeid'];
        }
        if (isset($options['operation'])) {
            $this->setOperation($options['operation']);
            if ($options['operation'] == 'delete') {
                $this->ignore404(true);
            }
        }
        if (isset($options['external-ids'])) {
            $this->extids = $options['external-ids'];
        }
    }
789554
protected function connect($configs = null): void
    {
        if ($configs !== null) {
            $this->configs = array_replace($this->configs, $configs);
        }

        $dsn = "{$this->configs['type']}:dbname={$this->configs['name']};host="
            . $this->configs['host'];
        try {
            $this->connection = new PDO(
                $dsn,
                $this->configs['user'],
                $this->configs['pass']
            );
            $this->connection->setAttribute(
                PDO::ATTR_ERRMODE,
                $this->configs['error_mode']
            );
        } catch (PDOException $e) {
            throw new CoreException(
                __CLASS__.'::__construct()->PDO::__construct() : ' . $e->getMessage()
            );
        }
    }
1273133
public function create(array $options = [])
    {
        $this->info = $this->connection->createTopic($options + [
            'name' => $this->name
        ]);

        return $this->info;
    }
832337
public function connect() : object
    {
        if ($this->options['verbose']) {
            echo "<p>Connecting to dsn:<br><code>" . $this->options['dsn'] . "</code>";
        }

        $this->loadHistory();
        return parent::connect();
    }
1025974
protected function configure(array $options): void
    {
        $options = array_merge([
            'socket_class' => ClientSocket::class,
            'on_data_callback' => null,
            'socket_options' => [],
        ], $options);

        parent::configure($options);
    }
1251676
public function connect() {
        if (!function_exists('\pg_connect')) throw new RuntimeException('Undefined function pg_connect(), pgsql extension is not available');

        $connStr = $this->getConnectionString();
        try {
            $php_errormsg = '';
            $this->hConnection = pg_connect($connStr, PGSQL_CONNECT_FORCE_NEW);
            !$this->hConnection && trigger_error($php_errormsg, E_USER_ERROR);
        }
        catch (\Exception $ex) {
            if (!$ex instanceof IRosasurferException)
                $ex = new DatabaseException($ex->getMessage(), $ex->getCode(), $ex);
            throw $ex->addMessage('Cannot connect to PostgreSQL server with connection string: "'.$connStr.'"');
        }

        $this->setConnectionOptions();
        return $this;
    }
64273
private function connect()
    {
        $this->conn = parent::getConn();
        $this->create = $this->conn->prepare($this->create);
    }
136194
public function addOptions( $options ) {
		foreach ( $options as $key => $option ) {
			if ( is_int( $key ) ) {
				$this->addOption( $option );
			} else {
				$this->addOption( $key, $option );
			}
		}
	}
188250
public function connect()
	{
		if ($this->connection)
		{
			return;
		}

		parent::connect();

		if (isset($this->options['schema']))
		{
			$this->setQuery('ALTER SESSION SET CURRENT_SCHEMA = ' . $this->quoteName($this->options['schema']))->execute();
		}

		$this->setDateFormat($this->dateformat);
	}
1219208
public function connect($driverOptions = array()) {
        if ($this->pdo === null) {
            if (is_array($driverOptions) && !empty($driverOptions)) {
                $this->config['driverOptions']= array_merge($this->config['driverOptions'], $driverOptions);
            }
            try {
                $this->pdo= new \PDO($this->config['dsn'], $this->config['username'], $this->config['password'], $this->config['driverOptions']);
            } catch (\PDOException $xe) {
                $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $xe->getMessage(), '', __METHOD__, __FILE__, __LINE__);
                return false;
            } catch (\Exception $e) {
                $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage(), '', __METHOD__, __FILE__, __LINE__);
                return false;
            }

            $connected= (is_object($this->pdo));
            if ($connected) {
                $connectFile = XPDO_CORE_PATH . 'om/' . $this->config['dbtype'] . '/connect.inc.php';
                if (!empty($this->config['connect_file']) && file_exists($this->config['connect_file'])) {
                    $connectFile = $this->config['connect_file'];
                }
                if (file_exists($connectFile)) include ($connectFile);
            }
            if (!$connected) {
                $this->pdo= null;
            }
        }
        $connected= is_object($this->pdo);
        return $connected;
    }