/** * constructor(string $dsn) * Connect to Interbase/Firebird. */ function __construct($dsn) { $p = DbSimpleGeneric::parseDSN($dsn); if (!is_callable('ibase_connect')) { return $this->_setLastError("-1", "Interbase/Firebird extension is not loaded", "ibase_connect"); } $ok = $this->link = ibase_connect($p['host'] . (empty($p['port']) ? "" : ":" . $p['port']) . ':' . preg_replace('{^/}s', '', $p['path']), $p['user'], $p['pass'], isset($p['CHARSET']) ? $p['CHARSET'] : 'win1251', isset($p['BUFFERS']) ? $p['BUFFERS'] : 0, isset($p['DIALECT']) ? $p['DIALECT'] : 3, isset($p['ROLE']) ? $p['ROLE'] : ''); if (isset($p['TRANSACTION'])) { $this->DbSimple_Ibase_BEST_TRANSACTION = eval($p['TRANSACTION'] . ";"); } $this->_resetLastError(); if (!$ok) { return $this->_setDbError('ibase_connect()'); } }
/** * constructor(string $dsn) * Connect to PostgresSQL. */ function __construct($dsn) { $p = DbSimpleGeneric::parseDSN($dsn); if (!is_callable('pg_connect')) { return $this->_setLastError("-1", "PostgreSQL extension is not loaded", "pg_connect"); } // Prepare+execute works only in PHP 5.1+. $this->DbSimple_Postgresql_USE_NATIVE_PHOLDERS = function_exists('pg_prepare'); $dsnWithoutPass = (!empty($p['host']) ? 'host=' . $p['host'] . ' ' : '') . (!empty($p['port']) ? 'port=' . $p['port'] . ' ' : '') . 'dbname=' . preg_replace('{^/}s', '', $p['path']) . ' ' . (!empty($p['user']) ? 'user='******'user'] : ''); $ok = $this->link = pg_pconnect($dsnWithoutPass . " " . (!empty($p['pass']) ? 'password='******'pass'] . ' ' : '')); // We use PGSQL_CONNECT_FORCE_NEW, because in PHP 5.3 & PHPUnit // $this->prepareCache may be cleaned, but $this->link is still // not closed. So the next creation of DbSimple_Postgresql() // would use exactly the same connection as the previous, but with // empty $this->prepareCache, and it will generate "prepared statement // xxx already exists" error each time we execute the same statement // as in the previous calls. $this->_resetLastError(); if (!$ok) { return $this->_setDbError('pg_connect("' . $dsnWithoutPass . '") error'); } }