cvs diff -u odbc.php
| From: | Richard M. Yumul | Date: | Fri, 01 Dec 2000 16:34:59 +0000 |
| Subject: | cvs diff -u odbc.php | ||
| Groups: | php.pear | ||
| Request: | Send a blank email to php-pear+get-468@lists.php.net to get a copy of this message | ||
Here's my diff's to odbc.php which should be easier to read:
Cheers,
Rich
Index: odbc.php
===================================================================
RCS file: /repository/php4/pear/DB/odbc.php,v
retrieving revision 1.16
diff -u -r1.16 odbc.php
--- odbc.php 2000/09/13 11:27:59 1.16
+++ odbc.php 2000/12/01 16:30:19
@@ -38,6 +38,7 @@
var $connection;
var $phptype, $dbsyntax;
+ var $fetchmode = DB_FETCHMODE_ORDERED;
// }}}
@@ -93,7 +94,7 @@
*
* @return int DB_OK on success, a DB error code on failure
*/
- function connect(&$dsn, $user, $pw) {
+ function connect(&$dsn, $user="", $pw="") {
if (is_array($dsn)) {
$dsninfo = &$dsn;
} else {
@@ -201,13 +202,37 @@
// }}}
// {{{ fetchRow()
- function fetchRow($result) {
+ /**
+ * Fetch a row and return as array.
+ *
+ * @param $result result identifier
+ * @param $fetchmode how the resulting array should be indexed
+ *
+ * @return mixed an array on success (associative or ordred, depending
on
+ * fetchmode), a false on failure, false if there is no
more
+ * data
+ */
+ function fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT) {
+ if ($fetchmode == DB_FETCHMODE_DEFAULT) {
+ $fetchmode = $this->fetchmode;
+ }
$cols = odbc_fetch_into($result, &$row);
if ($cols == 0) {
// XXX ERRORMSG
return false;
}
- return $row; // XXX ADDREF
+
+ if ($fetchmode == DB_FETCHMODE_ORDERED) {
+ return $row; // XXX ADDREF
+ } else if ($fetchmode == DB_FETCHMODE_ASSOC) {
+ for ($i = 0; $i < count($row); $i++) {
+ $colName = odbc_field_name($result, $i+1);
+ $a[$colName] = $row[$i];
+ }
+ return $a;
+ } else {
+ return false;
+ }
}
// }}}