fetchAll(PDO::FETCH_ASSOC) as $row){ $sroomID = $row['serverroomid']; $lastUpdate = $row['lastcalendarupdate']; $calendar = $row['calendar']; //Check if in cache if lastUpdate is null then it is interpreted as 1970 if(strtotime($lastUpdate) > strtotime("-".$this->getCacheTime()."seconds") && $this->getCacheTime()>0) { $result[$row['locationid']]=$calendar; } else { $sroomIDs[$row['locationid']] = $sroomID; } } //Check if we should refresh other rooms recently requested by front ends if ($this->getCacheTime()>0&&$this->getRefreshTime()>0) { $dbquery4 = Database::simpleQuery("SELECT locationid ,serverroomid, lastcalendarupdate FROM location_info WHERE serverid= :id", array('id' => $this->serverID)); foreach($dbquery4->fetchAll(PDO::FETCH_COLUMN) as $row){ if(strtotime($row['lastcalendarupdate'])>strtotime("-".$this->getRefreshTime()."seconds")&&strtotime($row['lastcalendarupdate'])> strtotime("-".$this->getCacheTime()."seconds")){ $sroomIDs[$row['locationid']] = $row['serverroomid']; } } } $results = $this->fetchSchedulesInternal($sroomIDs); foreach ($sroomIDs as $location => $serverroom){ $newresult[$location] = $results[$serverroom]; } if($this->getCacheTime()>0){ foreach ($newresult as $key => $value) { $now = strtotime('Now'); $dbquery1 = Database::simpleQuery("UPDATE location_info SET calendar = :ttable, lastcalendarupdate = :now WHERE locationid = :id ", array('id' => $key,'ttable' => $value,'now'=> $now)); } } //get all sheduls that are wanted from roomIDs foreach($roomIDs as $id){ $result[$id] = $newresult[$id]; } return $result; } /** * @return false if there was no error string with error message if there was one */ public final function getError(){ if($this->error){ return $this->errormsg; } return false; } }