
Public Member Functions | |
| walk ($query, array $callbacks, array $args=array()) | |
Protected Member Functions | |
| _getStatement ($query, $conn=null) | |
Definition at line 32 of file Iterator.php.
| _getStatement | ( | $ | query, | |
| $ | conn = null | |||
| ) | [protected] |
Fetch Zend statement instance
| Zend_Db_Statement_Interface|Zend_Db_Select|string | $query | |
| Zend_Db_Adapter_Abstract | $conn |
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 over records fetched from query one by one using callback function
| Zend_Db_Statement_Interface|Zend_Db_Select|string | $query | |
| array|string | $callback | |
| array | $args |
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 }
1.5.8