cvs: php4 /pear/DB pgsql.php
| From: | Rui Hirokawa | Date: | Thu, 07 Dec 2000 14:26:56 +0000 |
| Subject: | cvs: php4 /pear/DB pgsql.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-3005@lists.php.net to get a copy of this message | ||
hirokawa Thu Dec 7 06:26:56 2000 EDT
Modified files:
/php4/pear/DB pgsql.php
Log:
Added affectedRows (thanks to Mark Kirkwood <markir@i4free.co.nz>)
Index: php4/pear/DB/pgsql.php
diff -u php4/pear/DB/pgsql.php:1.14 php4/pear/DB/pgsql.php:1.15
--- php4/pear/DB/pgsql.php:1.14 Tue Sep 26 07:23:54 2000
+++ php4/pear/DB/pgsql.php Thu Dec 7 06:26:56 2000
@@ -37,7 +37,7 @@
//
// 3. The transaction is supported by PostgreSQL,
// but the current implementation is not useful to use the transaction.
-
+//
//
// XXX legend:
@@ -57,6 +57,7 @@
var $prepare_types = array();
var $numrows;
var $row;
+ var $affected;
// }}}
@@ -73,6 +74,7 @@
$this->errorcode_map = array();
$this->numrows = array();
$this->row = array();
+ $this->affected = 0;
}
// }}}
@@ -171,6 +173,9 @@
$this->row[$result] = 0; // reset the row counter.
$this->numrows[$result] = pg_numrows($result);
return $resultObj;
+ } elseif (preg_match('/(INSERT|UPDATE|DELETE)/i', $query)) {
+ $this->affected = pg_cmdtuples($result);
+ return DB_OK;
} else {
return DB_OK;
}
@@ -201,6 +206,9 @@
$this->row[$result] = 0; // reset the row counter.
$this->numrows[$result] = pg_numrows($result);
return $result;
+ } elseif (preg_match('/(INSERT|UPDATE|DELETE)/i', $query)) {
+ $this->affected = pg_cmdtuples($result);
+ return DB_OK;
} else {
return DB_OK;
}
@@ -301,6 +309,7 @@
unset($this->prepare_types[$result]);
unset($this->row[$result]);
unset($this->numrows[$result]);
+ $this->affected = 0;
return true;
}
@@ -402,6 +411,9 @@
$this->row[$result] = 0; // reset the row counter.
$this->numrows[$result] = pg_numrows($result);
return $result;
+ } elseif (preg_match('/(INSERT|UPDATE|DELETE)/i', $realquery)) {
+ $this->affected = pg_cmdtuples($result);
+ return DB_OK;
} else {
return DB_OK;
}
@@ -447,10 +459,26 @@
// }}}
+ // {{{ affectedRows()
+
+ /**
+ * Gets the number of rows affected by the last query.
+ * if the last query was a select, returns 0.
+ *
+ * @return number of rows affected by the last query or DB_ERROR
+ */
+ function affectedRows() {
+ $result = $this->affected;
+ if ($result === false) {
+ return $this->raiseError();
+ }
+ return $result;
+ }
+ // }}}
+
// TODO/wishlist:
// simpleFetch
// simpleGet
- // affectedRows
// longReadlen
// binmode
}