Index: pgsql.php =================================================================== RCS file: /repository/pear/MDB/pgsql.php,v retrieving revision 1.7 diff -u -r1.7 pgsql.php --- pgsql.php 10 Jul 2002 10:56:41 -0000 1.7 +++ pgsql.php 15 Jul 2002 10:39:23 -0000 @@ -140,8 +140,11 @@ $function=($persistent ? "pg_pconnect" : "pg_connect"); if(!function_exists($function)) return($this->raiseError(DB_ERROR_UNSUPPORTED, NULL, NULL, "doConnect: PostgreSQL support is not available in this PHP configuration")); - $port = (IsSet($this->options["port"]) ? $this->options["port"] : ""); - $connect_string = "dbname=$database_name host=" . $this->host; + $port = (isSet($this->options["port"]) ? $this->options["port"] : ""); + $connect_string = "dbname=$database_name "; + if ($this->host != "") { + $connect_string .= " host=" . $this->host; + } if ($port != "") { $connect_string .= " port=" . strval($port); } @@ -172,8 +175,9 @@ if(!strcmp($this->connected_host, $this->host) && !strcmp($this->connected_port, $port) && !strcmp($this->selected_database, $this->database_name) - && ($this->opened_persistent == $this->options['persistent'])) - return(1); + && ($this->opened_persistent == $this->options['persistent'])) { + return(DB_OK); + } pg_Close($this->connection); $this->affected_rows = -1; $this->connection = 0; @@ -182,7 +186,8 @@ if(MDB::isError($this->connection)) { return $this->connection; } - if(!$this->auto_commit && !MDB::isError($trans_result = $this->query("BEGIN"))) { + + if(!$this->auto_commit && MDB::isError($trans_result = $this->_doQuery("BEGIN"))) { pg_Close($this->connection); $this->connection = 0; $this->affected_rows = -1; @@ -204,7 +209,7 @@ { if($this->connection != 0) { if(!$this->auto_commit) { - $this->query("END"); + $this->_doQuery("END"); } pg_Close($this->connection); $this->connection = 0; @@ -649,31 +654,31 @@ function autoCommit($auto_commit) { - if(((!$this->auto_commit) == (!$auto_commit))) { + if (((!$this->auto_commit) == (!$auto_commit))) { return (DB_OK); } - if($this->connection) { - if(!$this->Query($auto_commit ? "END" : "BEGIN")) + if ($this->connection) { + if (!$this->_doQuery($auto_commit ? "END" : "BEGIN")) return(0); } - $this->auto_commit=$auto_commit; + $this->auto_commit = $auto_commit; return($this->registerTransactionShutdown($auto_commit)); } function commit() { - if($this->auto_commit) { - return($this->SetError("Commit transaction","transaction changes are being auto commited")); + if ($this->auto_commit) { + return($this->raiseError(DB_ERROR, '', '', "Commit: transaction changes are being auto commited")); } - return($this->query("COMMIT") && $this->query("BEGIN")); + return($this->_doQuery("COMMIT") && $this->_doQuery("BEGIN")); } function rollback() { if($this->auto_commit) { - return($this->SetError("Rollback transaction","transactions can not be rolled back when changes are auto commited")); + return($this->raiseError(DB_ERROR, '', '', "Rollback: transactions can not be rolled back when changes are auto commited")); } - return($this->query("ROLLBACK") && $this->query("BEGIN")); + return($this->_doQuery("ROLLBACK") && $this->_doQuery("BEGIN")); } function fetch($result, $row, $field)