cvs: pear /Structures_DataGrid/DataGrid/DataSource DBTable.php

From: Date: Tue, 14 Nov 2006 21:47:34 +0000
Subject: cvs: pear /Structures_DataGrid/DataGrid/DataSource DBTable.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-43077@lists.php.net to get a copy of this message
wiesemann Tue Nov 14 21:47:34 2006 UTC Modified files: /pear/Structures_DataGrid/DataGrid/DataSource DBTable.php Log: - this idea of implementing streaming was a bad one => remove it (more senseful implementation follows later) http://cvs.php.net/viewvc.cgi/pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php?r1=1.22&r2=1.23&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php:1.22 pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php:1.23 --- pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php:1.22 Sat Nov 11 11:53:51 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource/DBTable.php Tue Nov 14 21:47:34 2006 @@ -21,9 +21,9 @@ * +----------------------------------------------------------------------+ * </pre> * - * CSV file id: $Id: DBTable.php,v 1.22 2006/11/11 11:53:51 wiesemann Exp $ + * CSV file id: $Id: DBTable.php,v 1.23 2006/11/14 21:47:34 wiesemann Exp $ * - * @version $Revision: 1.22 $ + * @version $Revision: 1.23 $ * @package Structures_DataGrid_DataSource_DBTable * @category Structures */ @@ -58,7 +58,7 @@ * for example, created your database table yourself and did not setup the $idx * array, you can use the 'primary_key' option to define the primary key field. * - * @version $Revision: 1.22 $ + * @version $Revision: 1.23 $ * @author Andrew S. Nagy <asnagy@php.net> * @author Mark Wiesemann <wiesemann@php.net> * @access public @@ -93,15 +93,7 @@ * @var int * @access private */ - var $_rowNum = null; - - /** - * Fetchmode for getting the rows from the result object - * - * @var int - * @access private - */ - var $_fetchMode = null; + var $_rowNum = null; /** * Constructor @@ -115,7 +107,6 @@ 'where' => null, 'params' => array())); $this->_setFeatures(array('multiSort' => true, - 'streaming' => true, 'writeMode' => true)); } @@ -152,12 +143,10 @@ * * @param integer $offset Offset (starting from 0) * @param integer $limit Limit - * @param boolean $streaming Whether the data should be streamed or not * @access public - * @return mixed If streaming is enabled, the 2D array of the - * records, otherwise, the query result object + * @return array The 2D Array of the records */ - function &fetch($offset = 0, $limit = null, $streaming = false) + function &fetch($offset = 0, $limit = null) { if (!empty($this->_sortSpec)) { foreach ($this->_sortSpec as $field => $direction) { @@ -180,45 +169,26 @@ } if (is_a($result, 'db_result')) { - $this->_fetchMode = DB_FETCHMODE_ASSOC; + $fetchmode = DB_FETCHMODE_ASSOC; } else { - $this->_fetchMode = MDB2_FETCHMODE_ASSOC; - } - - // if the data should be streamed, return only the result object, but - // don't fetch the records - if ($streaming) { - return $result; + $fetchmode = MDB2_FETCHMODE_ASSOC; } $recordSet = array(); // Fetch the Data if ($numRows = $result->numRows()) { - while ($record = $this->fetchRow($result)) { + while ($record = $result->fetchRow($fetchmode)) { $recordSet[] = $record; } } - return $recordSet; - } - - function fetchRow(&$result) - { - // try to fetch a row from the result - $record = $result->fetchRow($this->_fetchMode); - - // if there is no row, return - if ($record === false) { - return false; - } - - // if needed, determine the fields to render - if (!$this->_options['fields']) { - $this->setOptions(array('fields' => array_keys($record))); - } + // Determine fields to render + if (!$this->_options['fields'] && count($recordSet)) { + $this->setOptions(array('fields' => array_keys($recordSet[0]))); + } - return $record; + return $recordSet; } /**

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