Exemplo n.º 1
0
    foreach (array(PROJECT_MODELS, PROJECT_INCLUDE, PROJECT_CONTROLLERS) as $dir) {
        if (file_exists($dir . '/inc.cls.' . $class . '.php')) {
            require_once $dir . '/inc.cls.' . $class . '.php';
            break;
        }
    }
}
require_once PROJECT_CONTROLLERS . '/inc.cls.__topmodule.php';
// Fetch request URI
$g_szRequestUri = __TopModule::getRequestUri();
// Connect to db
require_once 'cfg_db.php';
require_once PROJECT_INC_DB . '/inc.cls.db_mysqli.php';
$db = new db_mysqli(SQL_HOST, SQL_USER, SQL_PASS, SQL_DB);
// Save db layer
require_once PROJECT_INC_DB . '/inc.cls.activerecordobject.php';
ActiveRecordObject::setDbObject($db);
// Define general functions
require_once PROJECT_INCLUDE . '/inc.functions.php';
// Assign new class name to existing superclass
//template::$class = 'mytemplate';
try {
    $application = __TopModule::run($g_szRequestUri);
    $application->exec();
} catch (InvalidURIException $ex) {
    exit('[' . date('Y-m-d H:i:s') . '] Page not found: ' . $g_szRequestUri);
} catch (AROException $ex) {
    exit('[' . date('Y-m-d H:i:s') . '] Model error: ' . $ex->getMessage());
} catch (DBException $ex) {
    exit('[' . date('Y-m-d H:i:s') . '] Database error: ' . $ex->getMessage());
}
 public static final function setDbObject($db)
 {
     self::$_db = $db;
 }
Exemplo n.º 3
0
 public static function finder($class = __CLASS__)
 {
     return parent::finder($class);
 }
 /**
  * Save the database abstraction layer object (just once)
  * Todo:
  * - Save one db object per table/ARO child and fetch the default one if none is set
  */
 public static final function setDbObject(db_generic $db)
 {
     self::$__db = $db;
 }