Esempio n. 1
0
 /**
  * Set JSON
  */
 private static function setJSON($file, $json)
 {
     if (!is_array($json)) {
         return false;
     }
     $json = json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
     if (!self::$handle) {
         return file_put_contents($file, $json);
     }
     if (!fwrite(self::$handle, $json)) {
         throw new Exception('JSONDB: Can\'t write data to file (' . $file . ')');
     }
     fclose(self::$handle);
     self::$handle = null;
     return $result;
 }