cvs: php4 /pear/DB odbc.php

From: Date: Thu, 02 Aug 2001 18:14:00 +0000
Subject: cvs: php4 /pear/DB odbc.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-405@lists.php.net to get a copy of this message
cox Thu Aug 2 14:14:00 2001 EDT Modified files: /php4/pear/DB odbc.php Log: fix fetchInto and added the fetch row by number feature Index: php4/pear/DB/odbc.php diff -u php4/pear/DB/odbc.php:1.33 php4/pear/DB/odbc.php:1.34 --- php4/pear/DB/odbc.php:1.33 Mon Jul 30 16:43:12 2001 +++ php4/pear/DB/odbc.php Thu Aug 2 14:13:59 2001 @@ -27,9 +27,6 @@ // XXX ERRORMSG: The error message from the odbc function should // be registered here. // -// TODO: -// - change fetchrow to use fetchInto -// - implement $rownum param in FetchInto (supported by odbc functions) // require_once 'DB/common.php'; @@ -166,51 +163,40 @@ // }}} // {{{ fetchRow() - /** - * 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) + function fetchRow($result, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null) { if ($fetchmode == DB_FETCHMODE_DEFAULT) { $fetchmode = $this->fetchmode; } - $cols = odbc_fetch_into($result, &$row); + $res = $this->fetchInto ($result, $arr, $fetchmode, $rownum); + if ($res !== DB_OK) { + return $res; + } + return $arr; + } + + // }}} + // {{{ fetchInto() + + function fetchInto($result, &$row, $fetchmode, $rownum=null) + { + $rownum = ($rownum !== null) ? $rownum : $this->row[$result]; + $cols = odbc_fetch_into($result, $rownum, &$row); if (!$cols) { if ($errno = odbc_error($this->connection)) { return $this->raiseError($errno); - } else { - return null; } + return null; } - if ($fetchmode == DB_FETCHMODE_ORDERED) { - return $row; - } elseif ($fetchmode == DB_FETCHMODE_ASSOC) { + if ($fetchmode !== DB_FETCHMODE_ORDERED) { for ($i = 0; $i < count($row); $i++) { $colName = odbc_field_name($result, $i+1); $a[$colName] = $row[$i]; } - return $a; - } else { - return $this->raiseError(); // XXX ERRORMSG - } - } - - function fetchInto($result, &$row, $fetchmode, $rownum=null) - { - if ($rownum !== null) { - return $this->raiseError(DB_ERROR_UNSUPPORTED); + $row = $a; } - if (is_array($row = $this->fetchRow($result, $fetchmode))) { - return DB_OK; - } - return $row; + $this->row[$result] = ++$rownum; + return DB_OK; } // }}}

« previous php.pear.cvs (#405) next »