Ejemplo n.º 1
0
 /**
  * setups db using activerecord
  */
 public static function PRE_init_db()
 {
     # init activerecord configs
     \ActiveRecord\Config::initialize(function ($cfg) {
         # fetching db related configurations
         $dbcfg = \zinux\kernel\application\config::GetConfig("idisqus.db");
         # setting connection string
         $cfg->set_connections(array(\application\dbBootstrap::MODE_TORATAN => "{$dbcfg["type"]}://{$dbcfg["username"]}:{$dbcfg["password"]}@{$dbcfg["host"]}/{$dbcfg["name"]}?charset=utf8"));
         # enable the connection string as to \application\dbBootstrap::MODE_TORATAN
         $cfg->set_default_connection(\application\dbBootstrap::MODE_TORATAN);
     });
     # set default datetime format
     \ActiveRecord\DateTime::$DEFAULT_FORMAT = "iso8601";
     # testing db connection
     \ActiveRecord\Connection::instance();
     # if we reach here we are all OK
 }
Ejemplo n.º 2
0
<?php

header('Content-Type: text/html; charset=utf-8');
define('PATH_LIBS', $_SERVER['DOCUMENT_ROOT'] . '/../libs/');
define('SERVER_DIR', $_SERVER['DOCUMENT_ROOT'] . '/../');
require PATH_LIBS . 'flight/Flight.php';
error_reporting(E_ERROR);
require PATH_LIBS . 'phpactiverecord/ActiveRecord.php';
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory($_SERVER['DOCUMENT_ROOT'] . '/../app/Models');
    $cfg->set_connections(array('development' => 'mysql://*****:*****@localhost/vzapertiru_quest?charset=utf8'));
});
ActiveRecord\Connection::$datetime_format = 'Y-m-d';
ActiveRecord\Connection::$date_format = 'Y.m.d';
ActiveRecord\Serialization::$DATETIME_FORMAT = 'Y-m-d';
ActiveRecord\DateTime::$DEFAULT_FORMAT = 'Y-m-d';
Flight::set('flight.views.path', SERVER_DIR . 'view/template/');
require $_SERVER['DOCUMENT_ROOT'] . '/../config/classes.php';
Auth::getInstance()->init();
require SERVER_DIR . 'config/routes.php';
Flight::start();
Ejemplo n.º 3
0
<?php

/**active record setup
 * exemplo sqlite
 * 'sqlite' => 'sqlite://my_database.db',
 * 
*/
$cfg = ActiveRecord\Config::instance();
$cfg->set_model_directory('models');
$cfg->set_connections(array('development' => 'mysql://root:@localhost/development_db', 'test' => 'mysql://*****:*****@localhost/test_database_name', 'production' => 'mysql://*****:*****@localhost/production_database_name'));
//Não muito necesaria
ActiveRecord\DateTime::$DEFAULT_FORMAT = 'd-m-Y';
#d-m-Y short
ActiveRecord\DateTime::$FORMATS['awesome_format'] = 'H:i:s m/d/Y';