Ejemplo n.º 1
0
 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');
 }
Ejemplo n.º 2
0
 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);
             };
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * 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};
 }
Ejemplo n.º 4
0
 /**
  * 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);
 }