cvs: /php4/pear/DB pgsql.php

From: Date: Sun, 20 Feb 2000 08:40:36 +0000
Subject: cvs: /php4/pear/DB pgsql.php
Groups: php.version4 
Request: Send a blank email to php-version4+get-10516@lists.php.net to get a copy of this message
hirokawa Sun Feb 20 00:40:36 2000 EDT Modified files: /php4/pear/DB pgsql.php Log: the row index is changed to an array. Index: php4/pear/DB/pgsql.php diff -u php4/pear/DB/pgsql.php:1.2 php4/pear/DB/pgsql.php:1.3 --- php4/pear/DB/pgsql.php:1.2 Thu Feb 17 12:21:02 2000 +++ php4/pear/DB/pgsql.php Sun Feb 20 00:40:06 2000 @@ -29,15 +29,20 @@ // it will break completely because both result sets will be using the // same row counter. Solution: change $this->row into an array indexed // by resource id. +// --> $this->row is changed to an indexed array. (R.Hirokawa) // // 2. The pgsql extension currently does not have error codes. This // should be fixed so DB_pgsql can do portable error codes. +// --> The error codes are not supported in the current pgsql API (libpq). // +// 3. The transaction is supported by PostgreSQL, +// but the current implementation is not useful to use the transaction. + // // XXX legend: // -// XXX ERRORMSG: The error message from the mysql function should +// XXX ERRORMSG: The error message from the pgsql function should // be registered here. // @@ -66,10 +71,10 @@ $this->features = array( 'prepare' => false, 'pconnect' => true, - 'transactions' => false + 'transactions' => true ); $this->errorcode_map = array(); - $row = 0; + $this->row = array(); } // }}} @@ -149,6 +154,8 @@ if (!$result) { return pg_errormessage($this->connection); } + $this->row[$result] = 0; // reset the row counter. + // Determine which queries that should return data, and which // should return an error code only. if (preg_match('/(SELECT|SHOW)/i', $query)) { @@ -177,6 +184,8 @@ if (!$result) { return pg_errormessage($this->connection); } + $this->row[$result] = 0; // reset the row counter. + // Determine which queries that should return data, and which // should return an error code only. if (preg_match('/(SELECT|SHOW)/i', $query)) { @@ -200,9 +209,9 @@ */ function &fetchRow($result, $getmode = DB_GETMODE_DEFAULT) { if ($getmode & DB_GETMODE_ASSOC) { - $row = pg_fetch_array($result, $this->row); + $row = pg_fetch_array($result, $this->row[$result]); } else { - $row = pg_fetch_row($result, $this->row); + $row = pg_fetch_row($result, $this->row[$result]); } if (!$row) { $err = pg_errormessage($this->connection); @@ -211,7 +220,7 @@ } return $err; } - $this->row++; + $this->row[$result]++; return $row; } @@ -229,17 +238,22 @@ */ function fetchInto($result, &$arr, $getmode = DB_GETMODE_DEFAULT) { if ($getmode & DB_GETMODE_ASSOC) { - $arr = pg_fetch_array($result, $this->row); + $arr = pg_fetch_array($result, $this->row[$result]); } else { - $arr = pg_fetch_row($result, $this->row); + $arr = pg_fetch_row($result, $this->row[$result]); } if (!$arr) { - $errno = pg_errormessage($this->connection); - if (!$errno) { + /* + $errno = pg_errormessage($this->connection); + if (!$errno) { return NULL; - } - return $errno; + } + return $errno; + */ + // the error codes are not supported in pgsql. + return DB_ERROR_NOT_CAPABLE; } + $this->row[$result]++; return DB_OK; } @@ -262,6 +276,7 @@ } unset($this->prepare_tokens[$result]); unset($this->prepare_types[$result]); + unset($this->row[$result]); return true; } @@ -312,7 +327,8 @@ */ function errorNative() { /* return pg_errormessage($this->connection); */ - return FALSE; + // the error codes are not supported in pgsql. + return DB_ERROR_NOT_CAPABLE; } // }}} @@ -378,10 +394,14 @@ // {{{ commit() /** - * Commit transactions on the current connection [not supported by PostgreSQL] + * Commit transactions on the current connection */ function commit() { - return DB_ERROR_NOT_CAPABLE; + $result = pg_exec($this->connection, "end;"); + if (!$result) { + return pg_errormessage($this->connection); + } + return DB_OK; } // }}} @@ -389,10 +409,13 @@ /** * Roll back all uncommitted transactions on the current connection. - * [not supported by PostgreSQL] */ function rollback() { - return DB_ERROR_NOT_CAPABLE; + $result = pg_exec($this->connection, "abort;"); + if (!$result) { + return pg_errormessage($this->connection); + } + return DB_OK; } // }}}

« previous php.version4 (#10516) next »