Mage_Core_Model_Resource_Iterator Class Reference

Inheritance diagram for Mage_Core_Model_Resource_Iterator:

Varien_Object

List of all members.

Public Member Functions

 walk ($query, array $callbacks, array $args=array())

Protected Member Functions

 _getStatement ($query, $conn=null)


Detailed Description

Active record implementation

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file Iterator.php.


Member Function Documentation

_getStatement ( query,
conn = null 
) [protected]

Fetch Zend statement instance

Parameters:
Zend_Db_Statement_Interface|Zend_Db_Select|string $query
Zend_Db_Adapter_Abstract $conn
Returns:
Zend_Db_Statement_Interface

Definition at line 68 of file Iterator.php.

00069     {
00070         if ($query instanceof Zend_Db_Statement_Interface) {
00071             return $query;
00072         }
00073 
00074         if ($query instanceof Zend_Db_Select) {
00075             return $query->query();
00076         }
00077 
00078         $hlp = Mage::helper('core');
00079 
00080         if (is_string($query)) {
00081             if (!$conn instanceof Zend_Db_Adapter_Abstract) {
00082                 Mage::throwException($hlp->__('Invalid connection'));
00083             }
00084             return $conn->query($query);
00085         }
00086 
00087         Mage::throwException($hlp->__('Invalid query'));
00088     }

walk ( query,
array callbacks,
array args = array() 
)

Walk over records fetched from query one by one using callback function

Parameters:
Zend_Db_Statement_Interface|Zend_Db_Select|string $query
array|string $callback
array $args
Returns:
Mage_Core_Model_Resource_Activerecord

Definition at line 42 of file Iterator.php.

00043     {
00044         $stmt = $this->_getStatement($query);
00045 
00046         $args['idx'] = 0;
00047         while ($row = $stmt->fetch()) {
00048             $args['row'] = $row;
00049             foreach ($callbacks as $callback) {
00050                 $result = call_user_func($callback, $args);
00051                 if (!empty($result)) {
00052                     $args = array_merge($args, $result);
00053                 }
00054             }
00055             $args['idx']++;
00056         }
00057 
00058         return $this;
00059     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:00 2009 for Magento by  doxygen 1.5.8