cvs: pear /MDB2 MDB2.php

From: Date: Fri, 30 Apr 2004 14:33:38 +0000
Subject: cvs: pear /MDB2 MDB2.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-19023@lists.php.net to get a copy of this message
lsmith Fri Apr 30 10:33:38 2004 EDT Modified files: /pear/MDB2 MDB2.php Log: - fixed issues in fetchAll and fetchRow due to MDB2_FETCHMODE_OBJECT http://cvs.php.net/diff.php/pear/MDB2/MDB2.php?r1=1.27&r2=1.28&ty=u Index: pear/MDB2/MDB2.php diff -u pear/MDB2/MDB2.php:1.27 pear/MDB2/MDB2.php:1.28 --- pear/MDB2/MDB2.php:1.27 Thu Apr 29 18:40:31 2004 +++ pear/MDB2/MDB2.php Fri Apr 30 10:33:38 2004 @@ -43,7 +43,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: MDB2.php,v 1.27 2004/04/29 22:40:31 lsmith Exp $ +// $Id: MDB2.php,v 1.28 2004/04/30 14:33:38 lsmith Exp $ // /** @@ -1157,7 +1157,7 @@ { switch ($fetchmode) { case MDB2_FETCHMODE_OBJECT: - $this->objects['fetch_class'] = $object_class; + $this->options['fetch_class'] = $object_class; case MDB2_FETCHMODE_ORDERED: case MDB2_FETCHMODE_ASSOC: $this->fetchmode = $fetchmode; @@ -2726,22 +2726,30 @@ { $all = array(); while (!MDB2::isError($row = $this->fetchRow($fetchmode)) && $row) { - if ($rekey && count($row) < 2) { - return $this->mdb->raiseError(MDB2_ERROR_TRUNCATED); + if ($rekey) { + if((is_array($row) && count($row) < 2) + || (is_object($row) && count(get_object_vars($row)) < 2) + ) { + return $this->mdb->raiseError(MDB2_ERROR_TRUNCATED); + } } if ($rekey) { - if ($fetchmode & MDB2_FETCHMODE_ASSOC) { + if ($fetchmode == MDB2_FETCHMODE_ASSOC) { $key = reset($row); unset($row[key($row)]); - } elseif ($fetchmode & MDB2_FETCHMODE_OBJECT) { + } elseif ($fetchmode === MDB2_FETCHMODE_OBJECT) { $arr = get_object_vars($row); $key = reset($arr); - unset($arr->{key($row)}); +# unset($row->{key($arr)}); } else { $key = array_shift($row); } - if (!$force_array && count($row) == 1) { - $row = array_shift($row); + if (!$force_array) { + if(is_array($row) && count($row) == 1) { + $row = array_shift($row); + }# else if(is_object($row) && count($arr = get_object_vars($row)) == 1) { + # $row = array_shift($arr); + #} } if ($group) { $all[$key][] = $row; @@ -2882,6 +2890,30 @@ } // }}} +// {{{ class MDB2_Row + +/** + * Pear MDB2 Row Object + * @see MDB2_Driver_Common::setFetchMode() + */ +class MDB2_Row +{ + // {{{ constructor + + /** + * constructor + * + * @param resource row data as array + */ + function MDB2_Row(&$row) + { + foreach ($row as $key => $value) { + $this->$key = &$row[$key]; + } + } +} + +// }}} // {{{ MDB2_defaultDebugOutput() /**

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