public function nextObject()
 {
     //error_log("get next object...");
     if (!isset($this->iterator)) {
         if (isset($this->managed_objects)) {
             $this->array_iterator_location = 0;
             $this->managed_object;
         } else {
             if (!$this->loaded && $this->canUseMemcache() && EAMemCache::isAvailable()) {
                 $primary_key = $this->get_primary_key();
                 $sql = $this->select_for_memcache();
                 if (isset($primary_key) && isset($sql)) {
                     if ($results = $this->db()->query($sql)) {
                         $this->iterator_type = "memcache";
                         $this->iterator = $results;
                     }
                 }
             }
         }
         if (!isset($this->iterator)) {
             $sql = $this->select();
             //	error_log($sql);
             if (isset($sql)) {
                 if ($result = $this->db()->query($sql)) {
                     $this->iterator_type = "normal";
                     $this->iterator = $result;
                 }
             }
         }
         //error_log("type: {$this->iterator_type}");
     }
     if (is_array($this->iterator)) {
         if (!isset($this->iterator[$this->array_iterator_location])) {
             return $this->iterator[$this->array_iterator_location];
         }
     } else {
         $obj = $this->iterator->fetch_object();
         if (isset($obj)) {
             if ($this->iterator_type == "memcache") {
                 $primary_key = $this->get_primary_key();
                 if (isset($primary_key)) {
                     //error_log("create with primary value {$obj->$primary_key}");
                     return $this->create_managed_object_with_primary_value($obj->{$primary_key});
                 }
             } else {
                 //error_log("create managed object...");
                 return $this->create_managed_object($obj);
             }
         }
     }
 }
 private function error_recently_sent()
 {
     Loader::load('utility', "memcache/MemCache");
     if (!EAMemCache::isAvailable()) {
         //error_log("memcache not available for ErrorHandler. no email alert sent");
         return true;
     }
     $result = EAMemCache::get($this->getMemCacheKey(), time());
     if (isset($result) && $result > strtotime("-10 minutes")) {
         //error_log("error has been emailed in the last X minutes. do not sent email alert. $memCacheKey - $result");
         return true;
     }
     //error_log("update/set current error. $memCacheKey - $result");
     EAMemCache::set($this->getMemCacheKey(), time());
     return false;
 }