DB_FETCHMODE_ASSOC support in DB/odbc.php
| From: | Richard M. Yumul | Date: | Wed, 29 Nov 2000 17:34:39 +0000 |
| Subject: | DB_FETCHMODE_ASSOC support in DB/odbc.php | ||
| Groups: | php.pear | ||
| Request: | Send a blank email to php-pear+get-463@lists.php.net to get a copy of this message | ||
Hi all - I added the DB_FETCHMODE_ASSOC support to the fetchRow() method in
odbc.php. My diff's follow. I did it using:
diff odbc.php mynewodbc.php.
If I diffed it wrong, just let me know & I can fix it. Here it is:
40a41
> var $fetchmode = DB_FETCHMODE_ORDERED;
96c97
< function connect(&$dsn, $user, $pw) {
---
> function connect(&$dsn, $user="", $pw="") {
204c205,218
< 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;
> }
210c224,235
< 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;
> }
Richard M. Yumul
Web Developer
Polexis, Inc.
Direct: 619-542-7209
Fax: 619-542-8675
http://www.polexis.com
transforming data into knowledge