static function get_instance()
 {
     if (system_base_Wet_db_cache::$db === null) {
         system_base_Wet_db_cache::$db = system_base_Database::get_instance("mysql", null, null, null, null, null, null, null);
     }
     return system_base_Wet_db_cache::$db;
 }
Example #2
0
 static function cached_query($sql_cmd, $args = null, $dirty_pages = null)
 {
     $s_args = $args->join(":");
     $header = _hx_string_or_null($sql_cmd) . _hx_string_or_null($s_args);
     $filename = _hx_string_or_null(system_base_Wet_base::$cache_path) . _hx_string_rec(system_base_Hashes::do_hash($header), "");
     $resultset = null;
     $cached_results = null;
     $rows = new HList();
     $data = null;
     $total_rows = null;
     $results = null;
     $return_data = _hx_anonymous(array("rows" => $rows, "total_rows" => 0));
     if (strtoupper(_hx_substr(ltrim($sql_cmd), 0, 6)) !== "SELECT") {
         system_base_Database::get_instance(null, null, null, null, null, null, null, null);
         $resultset = system_base_Database::query($sql_cmd, $args, null);
         return _hx_anonymous(array("rows" => $resultset->results(), "total_rows" => $resultset->get_length()));
     }
     if (file_exists($filename)) {
         $fin = sys_io_File::read($filename, false);
         $results = $fin->readLine();
         if ($results === $header) {
             $cached_results = $fin->readLine();
             $return_data = haxe_Unserializer::run($cached_results);
         } else {
             $m = "Database cache collision running query: " . _hx_string_or_null($sql_cmd) . "\n";
             $m = Std::string(Date::now()) . ": " . _hx_string_or_null($m);
             system_base_Database::get_instance(null, null, null, null, null, null, null, null);
             $resultset = system_base_Database::query($sql_cmd, $args, null);
             return _hx_anonymous(array("rows" => $resultset->results(), "total_rows" => $resultset->get_length()));
         }
     } else {
         system_base_Database::get_instance(null, null, null, null, null, null, null, null);
         $resultset = system_base_Database::query($sql_cmd, $args, null);
         $data = haxe_Serializer::run(_hx_anonymous(array("rows" => $resultset->results(), "total_rows" => $resultset->get_length())));
         $fout = sys_io_File::write($filename, false);
         $fout->writeString(_hx_string_or_null($header) . "\n");
         $fout->writeString(_hx_string_or_null($data) . "\n");
         $fout->close();
     }
     return $return_data;
 }
Example #3
0
 static function explain_all()
 {
     $profiler = system_base_Profiler::get_instance();
     $db = system_base_Database::get_instance(null, null, null, null, null, null, null, null);
     if (strlen($profiler->get("SEL")->slow_sql) > 1) {
         system_base_Cache::$profile_buffer->append("<div class=\"__webrathea_debug__\">Webrathea Engine Slow Query Analysys</div>");
         system_base_Cache::$profile_buffer->append($db->explain($profiler->get("SEL")->slow_sql, false));
     }
 }