Example #1
0
 public function run($fetch_type = PDO::FETCH_OBJ, $debug = false)
 {
     $result = null;
     try {
         //static function cachedQuery($query, $args = [], $cachedName = null) {
         if ($this->cache_name) {
             $result = DB::cachedQuery($this->query_string, [], $this->cache_name);
             $this->disable_cache();
             $this->query_string = '';
             return $result;
         } else {
             $result = DB::query($this->query_string);
             if ($debug) {
                 return $this->query_string;
             }
             $this->query_string = '';
             if ($fetch_type) {
                 return $result->fetchAll($fetch_type);
             } else {
                 return $result;
             }
         }
     } catch (PDOException $e) {
         Template::throw_error($e->getMessage());
     }
 }
Example #2
0
        $file2 = $global['root'] . '/models/' . $class . '.php';
        if (file_exists($file2)) {
            require_once $file2;
        } else {
            exit("Could not load {$class} module");
        }
    } else {
        require_once "/var/www/charles_lib/{$class}.php";
    }
});
$page = basename(urldecode(strtolower(isset($_GET['t']) && !empty($_GET['t']) ? $_GET['t'] : (isset($global['default']) ? $global['default'] : 'index'))));
if (!file_exists($global['root'] . "/controllers/{$page}.php")) {
    Template::throw_error('Page not found: ' . $page);
} else {
    include_once $global['root'] . "/controllers/{$page}.php";
    $args = explode('/', @$_GET['arg']);
    $template = new $page();
    $method = empty($args[0]) ? 'index' : $args[0];
    try {
        if (!in_array($method, get_class_methods($template))) {
            Template::throw_error('Page not found: ' . $page . '/' . $method);
        }
        $error = $template->{$method}(array_splice($args, 1));
        if (!empty($error)) {
            die($error);
        }
    } catch (Exception $e) {
        Template::throw_error($e->getMessage());
    }
    $template->out();
}