示例#1
0
 public static function set_db_config($db_config)
 {
     if (!utils::key_exists(array("host", "user", "pass", "name", "tpfx"), $db_config)) {
         throw new Exception("Invalid Database Connection Information.");
     }
     self::$db_config = $db_config;
     self::$tbl_pfx = $db_config['tpfx'];
 }
示例#2
0
 protected static function _init($settings)
 {
     if (!utils::key_exists(array("table", "class"), $settings)) {
         die("Active Record: Invalid Configuration");
     }
     self::$tbl_pfx = parent::$tbl_pfx;
     self::$settings = $settings;
     self::make_instance();
 }
示例#3
0
 public static function route($config, $re_route)
 {
     $router_vars = self::get_router_vars($config);
     if (count($router_vars) > 1) {
         if (utils::key_exists(array($router_vars['controller']), $re_route)) {
             if (in_array($router_vars['action'], $re_route[$router_vars['controller']])) {
                 $router_vars['controller'] = $router_vars['action'];
                 $router_vars['action'] = !empty($router_vars['fnc_args']) ? $router_vars['fnc_args'][0] : $config['action'];
                 if (count($router_vars['fnc_args']) > 1) {
                     array_shift($router_vars['fnc_args']);
                 } else {
                     $router_vars['fnc_args'] = array();
                 }
             }
         }
     }
     if ($router_vars['controller'] == "base") {
         $router_vars['controller'] = $config['class'];
     }
     if (!file_exists(APP . 'controllers' . DS . $router_vars['controller'] . '.php')) {
         throw new NotFoundException();
     }
     require_once APP . 'controllers' . DS . $router_vars['controller'] . '.php';
     if (!class_exists($router_vars['controller'])) {
         throw new NotFoundException();
     }
     $instance = new $router_vars['controller']();
     if (!method_exists($instance, $router_vars['action'])) {
         throw new NotFoundException();
     }
     $instance->{$router_vars}['action']($router_vars['fnc_args'], $router_vars['gets']);
     if (DEBUG) {
         debug::set("router", "router", $router_vars);
         debug::set("session", "session", session::get_all());
         debug::show();
     }
 }