예제 #1
0
        self::$memory[$index] = memory_get_usage();
    }
    public static function get_cost($index = 'coreMain')
    {
        return number_format(microtime(true) - self::$time[$index], 4) . ' seconds of execution; ' . self::formatbytes(memory_get_usage() - self::$memory[$index]) . ' used in memory';
    }
    public static function saved_costs($index = 'coreMain')
    {
        return isset(self::$time[$index]);
    }
    private static function formatbytes($size)
    {
        $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
        return @round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[$i];
    }
    public static function isDebug()
    {
        return self::$debug;
    }
    public static function stringify($array)
    {
        $out = array();
        foreach ($array as $key => $value) {
            $out[$key] = (string) $value;
        }
        return $out;
    }
}
spl_autoload_register(function ($class) {
    _::declare_model($class);
});
예제 #2
0
<?php

// extras are loadeds since extras folder.
_::declare_extra('funciones');
// this function is execute automatically when this file is load
_::define_autocall(function () {
    // require a model
    // ATENTION: SINCE 1.0.1 VERSION, THIS IS NOT NECESSARY, USE AUTOLOAD, BUT THIS WORK ANYWAY FOR BACKWARD COMPATIBILITY
    _::declare_model('usuarios');
    // declare other model:
    _::declare_model('planes');
    // call user defined function.
    basic_headers();
});
// this define a controller home
// is called by url param, you see index.php for more info.
_::define_controller('home', function () {
    // checkLogin is user defined function.
    // _::redirect is a framework function to make a internal redirection (without header(location))
    // the first param is the name of te controller to be called.
    // you able to add second param to force redirect using header('LOCATION ');, but in this case, you need use url in the first param.
    if (!checkLogin()) {
        _::redirect('login');
        return false;
    }
    // this call to function show of the TPL manager, in this case using the default template manager
    // and like include index.tpl
    _::$view->show('index');
});
// define a login controller (for example).
_::define_controller('login', function () {
예제 #3
0
/**
 * in this time, I define a controller:
 * I can define one or more controllers in one file.
 * We recommends depending of case, if you need low cost application (talking about resources), you define one controller per file
 * If you need sort the code, you can define more controllers in one file.
 */
_::define_controller('example', function () {
    // my code here...
});
// define other controller
// in this controller is exampled the use of models
_::define_controller('example_2', function () {
    // my code here...
    // declare need model example
    // this is not necessary since version 1.0.1
    _::declare_model('example');
    // making new record void
    $record = new example();
    // put value in the field of record
    $record->field_example = 'value of example';
    // in this case, insert new record in the table example
    // and return id of the new record
    $lastInsertID = $record->save();
    // in this case, use id for load record
    $record = new example($lastInsertID);
    // this show string(16) "value of example"
    var_dump($record->field_example);
    // set new value
    $record->field_example = 'new value';
    var_dump($record->field_example);
    // now this show new value