result as $k=>$v) $c += count($v); return $c; } /** ArrayAccess **/ public function offsetExists($offset) { return isset($this->result[$offset]); } public function offsetGet($offset) { return $this->result[$offset]; } public function offsetSet($offset,$value) { if (isset($this->result[$offset])) $this->_count -= $this->result[$offset]->count(); $this->result[$offset] = $value; $this->_count += $value->count(); } public function offsetUnset($offset) { unset($this->result[$offset]); } /** Iterator **/ public function current() { if (! $this->_rewound) $this->rewind(); return current($this->result)->current(); } public function key() { return current($this->result)->key(); } public function next() { // If our current entry has more valid entries, skip to the next one. if (current($this->result)->valid() AND current($this->result)->next()->valid()) return current($this->result); // Skip to our next record next($this->result); // If the next record is invalid, keep jumping to find a valid record while (current($this->result) AND ! current($this->result)->valid()) if (next($this->result) === FALSE) break; // Rewind our current record if (is_object($this->result)) current($this->result)->rewind(); return current($this->result); } public function rewind() { is_resource($this->result) ? rewind($this->result) : reset($this->result); current($this->result)->rewind(); // If our current record is invalid, skip to the next one. if (! current($this->result)->valid()) $this->next(FALSE); $this->_rewound = TRUE; } public function valid() { return is_object(current($this->result)) ? current($this->result)->valid() : FALSE; } } // End Database_LDAP_Search_Result ?>