cvs: pear /DB/DB common.php

From: Date: Sat, 01 May 2004 02:42:11 +0000
Subject: cvs: pear /DB/DB common.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-19052@lists.php.net to get a copy of this message
danielc Fri Apr 30 22:42:11 2004 EDT Modified files: /pear/DB/DB common.php Log: Fix getCol() raising DB_ERROR_TRUNCATED when query produced no results. Change error for misnamed column to DB_ERROR_NOSUCHFIELD. http://cvs.php.net/diff.php/pear/DB/DB/common.php?r1=1.101&r2=1.102&ty=u Index: pear/DB/DB/common.php diff -u pear/DB/DB/common.php:1.101 pear/DB/DB/common.php:1.102 --- pear/DB/DB/common.php:1.101 Wed Apr 28 15:58:29 2004 +++ pear/DB/DB/common.php Fri Apr 30 22:42:11 2004 @@ -18,7 +18,7 @@ // | Maintainer: Daniel Convissor <danielc@php.net> | // +----------------------------------------------------------------------+ // -// $Id: common.php,v 1.101 2004/04/28 19:58:29 danielc Exp $ +// $Id: common.php,v 1.102 2004/05/01 02:42:11 danielc Exp $ require_once 'PEAR.php'; @@ -27,7 +27,7 @@ * inherited by all such * * @package DB - * @version $Id: common.php,v 1.101 2004/04/28 19:58:29 danielc Exp $ + * @version $Id: common.php,v 1.102 2004/05/01 02:42:11 danielc Exp $ * @category Database * @author Stig Bakken <ssb@php.net> * @author Tomas V.V.Cox <cox@idecnet.com> @@ -1343,14 +1343,16 @@ $fetchmode = is_int($col) ? DB_FETCHMODE_ORDERED : DB_FETCHMODE_ASSOC; - if (!is_array($row = $res->fetchRow($fetchmode)) || - !array_key_exists($col, $row)) - { - $ret =& $this->raiseError(DB_ERROR_TRUNCATED); + if (!is_array($row = $res->fetchRow($fetchmode))) { + $ret = array(); } else { - $ret = array($row[$col]); - while (is_array($row = $res->fetchRow($fetchmode))) { - $ret[] = $row[$col]; + if (!array_key_exists($col, $row)) { + $ret =& $this->raiseError(DB_ERROR_NOSUCHFIELD); + } else { + $ret = array($row[$col]); + while (is_array($row = $res->fetchRow($fetchmode))) { + $ret[] = $row[$col]; + } } }

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