function _connect($str, $user = '', $pwd = '', $db = '', $ctype = 0) { if (!function_exists('pg_connect')) { return null; } $this->_errorMsg = false; if ($user || $pwd || $db) { $user = adodb_addslashes($user); $pwd = adodb_addslashes($pwd); if (strlen($db) == 0) { $db = 'template1'; } $db = adodb_addslashes($db); if ($str) { $host = split(":", $str); if ($host[0]) { $str = "host=" . adodb_addslashes($host[0]); } else { $str = ''; } if (isset($host[1])) { $str .= " port={$host['1']}"; } else { if (!empty($this->port)) { $str .= " port=" . $this->port; } } } if ($user) { $str .= " user="******" password="******" dbname=" . $db; } } //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432"; if ($ctype === 1) { // persistent $this->_connectionID = pg_pconnect($str); } else { if ($ctype === -1) { // nconnect, we trick pgsql ext by changing the connection str static $ncnt; if (empty($ncnt)) { $ncnt = 1; } else { $ncnt += 1; } $str .= str_repeat(' ', $ncnt); } $this->_connectionID = pg_connect($str); } if ($this->_connectionID === false) { return false; } $this->Execute("set datestyle='ISO'"); $info = $this->ServerInfo(); $this->pgVersion = (double) substr($info['version'], 0, 3); if ($this->pgVersion >= 7.1) { // good till version 999 $this->_nestedSQL = true; } return true; }
function _connect($str, $user = '', $pwd = '', $db = '', $persist = false) { if ($user || $pwd || $db) { $str = adodb_addslashes($str); $user = adodb_addslashes($user); $pwd = adodb_addslashes($pwd); $db = adodb_addslashes($db); if ($str) { $host = split(":", $str); if ($host[0]) { $str = "host={$host['0']}"; } else { $str = 'localhost'; } if (isset($host[1])) { $str .= " port={$host['1']}"; } } if ($user) { $str .= " user="******" password="******" dbname=" . $db; } } //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432"; if ($persist) { $this->_connectionID = pg_pconnect($str); } else { $this->_connectionID = pg_connect($str); } if ($this->_connectionID === false) { return false; } $this->Execute("set datestyle='ISO'"); return true; }
function _connect($str, $user = '', $pwd = '', $db = '', $ctype = 0) { if (!function_exists('pg_pconnect')) { return false; } $this->_errorMsg = false; if ($user || $pwd || $db) { $user = adodb_addslashes($user); $pwd = adodb_addslashes($pwd); if (strlen($db) == 0) { $db = 'template1'; } $db = adodb_addslashes($db); if ($str) { $host = explode(":", $str); if ($host[0]) { $str = "host=" . adodb_addslashes($host[0]); } else { $str = 'host=localhost'; } if (isset($host[1])) { $str .= " port={$host['1']}"; } } if ($user) { $str .= " user="******" password="******" dbname=" . $db; } } //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432"; if ($ctype === 1) { // persistent $this->_connectionID = pg_pconnect($str); } else { if ($ctype === -1) { // nconnect, we trick pgsql ext by changing the connection str static $ncnt; if (empty($ncnt)) { $ncnt = 1; } else { $ncnt += 1; } $str .= str_repeat(' ', $ncnt); } $this->_connectionID = pg_connect($str); } if ($this->_connectionID === false) { return false; } $this->Execute("set datestyle='ISO'"); return true; }
function _connect($str, $user = '', $pwd = '', $db = '', $ctype = 0) { if (!function_exists('pg_connect')) { return null; } $this->_errorMsg = false; if ($user || $pwd || $db) { $user = adodb_addslashes($user); $pwd = adodb_addslashes($pwd); if (strlen($db) == 0) { $db = 'template1'; } $db = adodb_addslashes($db); if ($str) { $host = explode(":", $str); if ($host[0]) { $str = "host=" . adodb_addslashes($host[0]); } else { $str = ''; } if (isset($host[1])) { $str .= " port={$host['1']}"; } else { if (!empty($this->port)) { $str .= " port=" . $this->port; } } } if ($user) { $str .= " user="******" password="******" dbname=" . $db; } } //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432"; if ($ctype === 1) { // persistent $this->_connectionID = pg_pconnect($str); } else { if ($ctype === -1) { // nconnect, we trick pgsql ext by changing the connection str static $ncnt; if (empty($ncnt)) { $ncnt = 1; } else { $ncnt += 1; } $str .= str_repeat(' ', $ncnt); } $this->_connectionID = pg_connect($str); } if ($this->_connectionID === false) { return false; } $this->Execute("set datestyle='ISO'"); $info = $this->ServerInfo(); $this->pgVersion = (double) substr($info['version'], 0, 3); if ($this->pgVersion >= 7.1) { // good till version 999 $this->_nestedSQL = true; } # PostgreSQL 9.0 changed the default output for bytea from 'escape' to 'hex' # PHP does not handle 'hex' properly ('x74657374' is returned as 't657374') # https://bugs.php.net/bug.php?id=59831 states this is in fact not a bug, # so we manually set bytea_output if (!empty($this->connection->noBlobs) && version_compare($info['version'], '9.0', '>=')) { $this->Execute('set bytea_output=escape'); } return true; }
function _connect($str, $user = '', $pwd = '', $db = '', $ctype = 0) { if (!function_exists('pg_connect')) { return null; } $this->_errorMsg = false; if ($user || $pwd || $db) { $user = adodb_addslashes($user); $pwd = adodb_addslashes($pwd); if (strlen($db) == 0) { $db = 'template1'; } $db = adodb_addslashes($db); if ($str) { $host = split(":", $str); if ($host[0]) { $str = "host=" . adodb_addslashes($host[0]); } else { $str = 'host='; } // Modified 2004-07-23 by Kevin Jamieson (http://pkp.sfu.ca/) // Don't specify a host if none was entered (so will connect using sockets) if (isset($host[1])) { $str .= " port={$host['1']}"; } else { if (!empty($this->port)) { $str .= " port=" . $this->port; } } } if ($user) { $str .= " user="******" password="******" dbname=" . $db; } } //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432"; if ($ctype === 1) { // persistent $this->_connectionID = pg_pconnect($str); } else { if ($ctype === -1) { // nconnect, we trick pgsql ext by changing the connection str static $ncnt; if (empty($ncnt)) { $ncnt = 1; } else { $ncnt += 1; } $str .= str_repeat(' ', $ncnt); } $this->_connectionID = pg_connect($str); } if ($this->_connectionID === false) { return false; } $this->Execute("set datestyle='ISO'"); return true; }