cvs: pear /DB_DataObject DataObject.php

From: Date: Wed, 01 Mar 2006 01:46:31 +0000
Subject: cvs: pear /DB_DataObject DataObject.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-38758@lists.php.net to get a copy of this message
alan_k Wed Mar 1 01:46:31 2006 UTC Modified files: /pear/DB_DataObject DataObject.php Log: fix bug #6953 - Overzealous memory cleaning broke toArray() on joins, when fetching last row http://cvs.php.net/viewcvs.cgi/pear/DB_DataObject/DataObject.php?r1=1.405&r2=1.406&diff_format=u Index: pear/DB_DataObject/DataObject.php diff -u pear/DB_DataObject/DataObject.php:1.405 pear/DB_DataObject/DataObject.php:1.406 --- pear/DB_DataObject/DataObject.php:1.405 Wed Feb 22 03:36:28 2006 +++ pear/DB_DataObject/DataObject.php Wed Mar 1 01:46:31 2006 @@ -15,7 +15,7 @@ * @author Alan Knowles <alan@akbkhome.com> * @copyright 1997-2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: DataObject.php,v 1.405 2006/02/22 03:36:28 alan_k Exp $ + * @version CVS: $Id: DataObject.php,v 1.406 2006/03/01 01:46:31 alan_k Exp $ * @link http://pear.php.net/package/DB_DataObject */ @@ -253,7 +253,6 @@ */ var $N = 0; // Number of rows returned from a query - /* ============================================================= */ /* Major Public Methods */ /* (designed to be optionally then called with parent::method()) */ @@ -538,13 +537,20 @@ } // reduce the memory usage a bit... (but leave the id in, so count() works ok on it) unset($_DB_DATAOBJECT['RESULTS'][$this->_DB_resultid]); + + // we need to keep a copy of resultfields locally so toArray() still works + // however we dont want to keep it in the global cache.. + if (!empty($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid])) { + $this->_resultFields = $_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]; unset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]); } // this is probably end of data!! //DB_DataObject::raiseError("fetch: no data returned", DB_DATAOBJECT_ERROR_NODATA); return false; } + // make sure resultFields is always empty.. + $this->_resultFields = false; if (!isset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid])) { // note: we dont declare this to keep the print_r size down. @@ -1626,7 +1632,16 @@ * @access private * @var integer */ - var $_DB_resultid; // database result object + var $_DB_resultid; + + /** + * ResultFields - on the last call to fetch(), resultfields is sent here, + * so we can clean up the memory. + * + * @access public + * @var array + */ + var $_resultFields = false;; /* ============================================================== */ @@ -3366,7 +3381,9 @@ { global $_DB_DATAOBJECT; $ret = array(); - $ar = isset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]) ? + $rf = ($this->_resultFields !== false) ? $this->_resultFields : + (isset($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid]) ? $_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid] : false; + $ar = ($rf !== false) ? array_merge($_DB_DATAOBJECT['RESULTFIELDS'][$this->_DB_resultid],$this->table()) : $this->table();

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