Пример #1
0
 public static function getInstance($force = false)
 {
     if (USE_CACHE) {
         $data = unserialize($_SESSION[DATA_CACHE]);
         //check si l'existant est à jour
         if (!empty($data) && !$force) {
             $cacheId = DatabaseData::getCacheId();
             //echo "<div>".$data->uniq." ?= ".$cacheId."</div>";
             //echo "<div>Queries COUNT = ".count($data->queries)."</div>";
             if ($data->uniq != $cacheId) {
                 //echo "UniqId is different, need to reload cache";
                 $force = true;
             } else {
                 if (count($data->queries) < 1) {
                     $force = true;
                 }
             }
         }
         //reload
         if (empty($data) || $force) {
             //echo "DATABASEDATA :: getInstance > Forcing refresh of data";
             //echo "DatabaseData::getInstance >> (re)loading database";
             $data = new DatabaseData();
             $data->save();
         }
     } else {
         $data = new DatabaseData();
         //$data->save();
     }
     if (!isset($data)) {
         die("getInstance :: Should have data here");
     }
     if (empty($data)) {
         die("getInstance :: Data should not be empty");
     }
     //return OBJECT
     return $data;
 }