public function __construct($config = array()) { $this->db_config = array('driver' => 'sqlite', 'file' => STORAGE_PATH . 'sitesearch.sqlite', 'host' => 'localhost', 'db' => 'sitesearch_searchengine', 'user' => 'root', 'pass' => ''); // apply config foreach ($config as $key => $value) { $this->{$key} = $value; } $this->db = Factory::load('Db:dbsitesearch', $this->db_config); $this->bm = Factory::load('Benchmark:benchmarksitesearch'); }
public function __construct(array $config) { parent::__construct(); $this['config'] = array_merge(array('mode' => 'production', 'encoding' => 'utf8', 'namespace' => ''), $config); $this['db'] = function ($c) { $db = new Database($c['config']['db']); $db->execute("SET NAMES '" . $c['config']['encoding'] . "';"); return $db; }; $this['query'] = $this->factory(function ($c) { return new Query($c); }); if (isset($this['config']['tables']) && is_array($this['config']['tables'])) { $namespace = $this['config']['namespace']; if ($namespace) { $namespace .= '\\'; } foreach ($this['config']['tables'] as $classname => $tablename) { $this[$classname] = function ($c) use($classname, $tablename, $namespace) { return Factory::load($namespace . $classname, $c, $tablename); }; } } }
/** * Allows to access and instantiating a class by accessing an object member. * @param string $instance_identifier The instance identifier. * @return object Returns the created instance. */ public function __get($instance_identifier) { $this->{$instance_identifier} = Factory::load(ucfirst($instance_identifier)); return $this->{$instance_identifier}; }
/** * Dumps any number of variables to the screen. * @param mixed $variable Pass a variable number of arguments to this method * @return null */ public static function dump($variable) { $args = func_get_args(); echo Factory::load('Debug')->_dump($args); }