cvs: php4 /pear/DB STATUS odbc.php
| From: | Thomas V.V.Cox | Date: | Fri, 18 Jan 2002 15:37:04 +0000 |
| Subject: | cvs: php4 /pear/DB STATUS odbc.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1994@lists.php.net to get a copy of this message | ||
cox Fri Jan 18 10:37:04 2002 EDT
Modified files:
/php4/pear/DB odbc.php STATUS
Log:
added affectedRows() and test in numRows() if the backend
is capable of not to return this info
Index: php4/pear/DB/odbc.php
diff -u php4/pear/DB/odbc.php:1.49 php4/pear/DB/odbc.php:1.50
--- php4/pear/DB/odbc.php:1.49 Wed Dec 19 12:35:43 2001
+++ php4/pear/DB/odbc.php Fri Jan 18 10:37:03 2002
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: odbc.php,v 1.49 2001/12/19 17:35:43 cox Exp $
+// $Id: odbc.php,v 1.50 2002/01/18 15:37:03 cox Exp $
//
// Database independent query interface definition for PHP's ODBC
// extension.
@@ -167,9 +167,11 @@
// Determine which queries that should return data, and which
// should return an error code only.
if (DB::isManip($query)) {
+ $this->manip_result = $result; // For affectedRows()
return DB_OK;
}
$this->row[$result] = 0;
+ $this->manip_result = 0;
return $result;
}
@@ -273,6 +275,27 @@
}
// }}}
+ // {{{ affectedRows()
+
+ /**
+ * Returns the number of rows affected by a manipulative query
+ * (INSERT, DELETE, UPDATE)
+ * @return mixed int affected rows, 0 when non manip queries or
+ * DB error on error
+ */
+ function affectedRows()
+ {
+ if (empty($this->manip_result)) { // In case of SELECT stms
+ return 0;
+ }
+ $nrows = odbc_num_rows($this->manip_result);
+ if ($nrows == -1) {
+ return $this->odbcRaiseError();
+ }
+ return $nrows;
+ }
+
+ // }}}
// {{{ numRows()
/**
@@ -284,7 +307,11 @@
*/
function numRows($result)
{
- return odbc_num_rows($result);
+ $nrows = odbc_num_rows($result);
+ if ($nrows == -1) {
+ return $this->odbcRaiseError(DB_ERROR_UNSUPPORTED);
+ }
+ return $nrows;
}
// }}}
Index: php4/pear/DB/STATUS
diff -u php4/pear/DB/STATUS:1.29 php4/pear/DB/STATUS:1.30
--- php4/pear/DB/STATUS:1.29 Wed Oct 31 06:52:28 2001
+++ php4/pear/DB/STATUS Fri Jan 18 10:37:03 2002
@@ -14,11 +14,11 @@
FEATURE | ibase | msql | mysql | odbc | sybase
simpleQuery x x x x x T T x T x
numCols x x x x x T T x T x
-numRows x n n x x T E n T n
+numRows x n n x x T E x T n
errorNative x n x n n T x x T n
prepare/execute e x e e e E T e E e
sequences e n n n n E T n T n
-affectedRows x n x x n T T n T x
+affectedRows x n x x n T T x T x
fetch modes x x x x x T T x T x
fetch row by number x n x x x x n x x x
transactions x x n n x x x x x n