public function __construct() { if (!isset($_SESSION)) { session_start(); } $this->dbh = db_loader::connect(); }
function __construct() { $this->db = db_loader::get(db_loader::MOCK_CONNECTION, array('engine' => 'null')); $this->core = core::get_instance(); $this->prepare_fields(); }
function __construct() { $this->db = db_loader::get(array('engine' => 'null')); $this->core = core::get_instance(); $this->prepare_valid_fields(); }
<?php require '../../loader.php'; $config = array('engine' => 'pdo_sqlite', 'prefix' => 'sat_', 'path' => "config/localhost/database.db"); $connection = db_loader::get_doctrine('sqlite', $config); //$connection->connect(); // Doctrine\DBAL\Driver\PDOStatement // $row = ($connection->query("SELECT * from sat_test_images")->fetch()); /* dd($connection->createQueryBuilder() ->select('*') ->from('sat_test_images') ->execute() ->fetch() ); */ // test_assert(var_dump(), 'connected'); test_assert(!$connection->isConnected(), 'connected'); test_assert($connection->query("SELECT * FROM sqlite_master WHERE type='table' AND name LIKE 'sat_test_images'")->fetchAll()[0]['name'] == 'sat_test_images'); test_assert($connection->isConnected(), 'connected'); test_assert($connection->query("PRAGMA table_info('sat_test_images')")->fetchAll()[0]['name'] == 'id'); // dd($connection->query("PRAGMA index_info('sat_test_images')")->fetchAll());
/** * DB Setup * @param $id * @throws core_exception */ function configure_database($id) { if ($id) { if (is_array($id)) { $cfg = $id; } else { $id = 'database-' . $id; $cfg = $this->cfg($id); } } if (!$cfg || $this->cfg('options.skip_database')) { $cfg['engine'] = 'null'; self::dprint('Missing database configuration section', core::E_CRIT); } $connection = db_loader::set(null, $cfg); if (!$connection) { throw new core_exception('Database connection problem', tf_exception::CRITICAL); } // default connection self::register_lib('db', $connection); }
/** * INIT0 - call right after create an instance of core * create basic stuff * @throws core_exception */ public function init0() { // templates setup self::register_lib('tpl_parser', tpl_loader::factory()); // renderer self::register_lib('renderer', new tf_renderer($this->get_cfg_var('site_url') . loader::DIR_TEMPLATES . $this->get_cfg_var('template') . '/', self::lib('tpl_parser'))); // database setup self::register_lib('db', $db_test = db_loader::get($this->get_cfg_var('database'))); if (!$db_test && !defined('TF_TEST_INFECTED')) { throw new core_exception('Database connection problem', tf_exception::CRITICAL); } // set default timezone $tz = $this->get_cfg_var('default_timezone'); date_default_timezone_set($tz ? $tz : 'Europe/Moscow'); // load core config $this->dyn_config = $this->class_register('config', array('render_by_key' => true)); $this->dyn_config->merge_with($this->config); // add libs self::register_lib('logger', tf_logger::get_instance()); // ->enable(!$this->get_cfg_var('disable_logger', false)); if (!defined('TF_TEST_INFECTED')) { set_error_handler(create_function('$x, $y', 'if (0 != ini_get("error_reporting")) throw new system_exception($y, $x);'), E_ALL & ~E_NOTICE); } self::register_lib('manager', new tf_manager()); self::register_lib('validator', new tf_validator()); self::register_lib('request', new tf_request()); $modules_array = array(); if ('file' == $this->get_cfg_var('modules_config', '') && ($modules_config = loader::get_docs() . 'modules.cfg') && fs::file_exists($modules_config)) { $modules_array = parse_ini_file($modules_config, true); } else { try { $modules_array = $this->class_register('modules', array('key' => 'tag'))->as_array(); } catch (modules_exception $e) { // probably misconfigured modules table, some of modules not exists throw new core_exception($e->getMessage(), tf_exception::CRITICAL); } } // modules manager self::$modules = new modules_factory($modules_array); // finish core init0 proccess parent::init0(); // check bans if (!$this->get_cfg_var('no_bans_check') && isset($_SERVER['REQUEST_URI']) && ($_uri = $_SERVER['REQUEST_URI']) && !empty($_uri)) { if ($this->get_bans_handle()->check_spam($_uri)) { throw new core_exception($this->get_langword('you_are_banned'), tf_exception::CRITICAL); } } /* content type in autoload so convert it to object an destroy it */ if (self::in_editor()) { self::register_lib('editor', new tf_editor()); } // register auth if ($musers = $this->module('users')) { self::register_lib('auth', new tf_auth($musers, loader::in_shell())); } $this->initialized = true; }
public function __construct() { $this->dbh = db_loader::connect(); }