web/lib/Zend/Db/Table/Rowset/Abstract.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Db
    16  * @package    Zend_Db
    17  * @subpackage Table
    17  * @subpackage Table
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Abstract.php 23380 2010-11-18 22:22:28Z ralph $
    20  * @version    $Id: Abstract.php 24593 2012-01-05 20:35:02Z matthew $
    21  */
    21  */
    22 
    22 
    23 /**
    23 /**
    24  * @category   Zend
    24  * @category   Zend
    25  * @package    Zend_Db
    25  * @package    Zend_Db
    26  * @subpackage Table
    26  * @subpackage Table
    27  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    27  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    28  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    28  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    29  */
    29  */
    30 abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Countable, ArrayAccess
    30 abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Countable, ArrayAccess
    31 {
    31 {
    32     /**
    32     /**
   382             $row = $this->_loadAndReturnRow($position);
   382             $row = $this->_loadAndReturnRow($position);
   383         } catch (Zend_Db_Table_Rowset_Exception $e) {
   383         } catch (Zend_Db_Table_Rowset_Exception $e) {
   384             require_once 'Zend/Db/Table/Rowset/Exception.php';
   384             require_once 'Zend/Db/Table/Rowset/Exception.php';
   385             throw new Zend_Db_Table_Rowset_Exception('No row could be found at position ' . (int) $position, 0, $e);
   385             throw new Zend_Db_Table_Rowset_Exception('No row could be found at position ' . (int) $position, 0, $e);
   386         }
   386         }
   387         
   387 
   388         if ($seek == true) {
   388         if ($seek == true) {
   389             $this->seek($position);
   389             $this->seek($position);
   390         }
   390         }
   391         
   391 
   392         return $row;
   392         return $row;
   393     }
   393     }
   394 
   394 
   395     /**
   395     /**
   396      * Returns all data as an array.
   396      * Returns all data as an array.
   406         foreach ($this->_rows as $i => $row) {
   406         foreach ($this->_rows as $i => $row) {
   407             $this->_data[$i] = $row->toArray();
   407             $this->_data[$i] = $row->toArray();
   408         }
   408         }
   409         return $this->_data;
   409         return $this->_data;
   410     }
   410     }
   411     
   411 
   412     protected function _loadAndReturnRow($position)
   412     protected function _loadAndReturnRow($position)
   413     {
   413     {
   414         if (!isset($this->_data[$position])) {
   414         if (!isset($this->_data[$position])) {
   415             require_once 'Zend/Db/Table/Rowset/Exception.php';
   415             require_once 'Zend/Db/Table/Rowset/Exception.php';
   416             throw new Zend_Db_Table_Rowset_Exception("Data for provided position does not exist");
   416             throw new Zend_Db_Table_Rowset_Exception("Data for provided position does not exist");
   417         }
   417         }
   418         
   418 
   419         // do we already have a row object for this position?
   419         // do we already have a row object for this position?
   420         if (empty($this->_rows[$position])) {
   420         if (empty($this->_rows[$position])) {
   421             $this->_rows[$position] = new $this->_rowClass(
   421             $this->_rows[$position] = new $this->_rowClass(
   422                 array(
   422                 array(
   423                     'table'    => $this->_table,
   423                     'table'    => $this->_table,