Exemplo n.º 1
0
 public static function factory($name)
 {
     $assert = static::service('assert');
     $config = static::service('config');
     $config = $config->get('databases.#1', null, $name);
     $adapter = $config['adapter'];
     $assert->notNull($config, "There is no config for {$name}.");
     $assert->notNull($adapter, "Please define adapter to database {$name}.");
     return MidataAdapter::factory($adapter, $config, $name);
 }
Exemplo n.º 2
0
 public function get($source)
 {
     $assert = $this->service('assert');
     $config = $this->service('config');
     if (isset($this->inited[$source])) {
         return $this->inited[$source];
     }
     $config = $config->get("sources.{$source}");
     $assert->notNull($config, "The config of {$source} is not defined.");
     $assert->hasIndex($config, 'adapter', 'Each source config should have defined adapter.');
     $adapter = MidataAdapter::factory($config['adapter'], $config, $source);
     $adapter = new ORMAdapter($adapter);
     return $this->inited[$source] = $adapter;
 }
Exemplo n.º 3
0
 public function adapter()
 {
     return Adapter::factory('mysql', array('adapter' => 'mysql', 'host' => 'localhost', 'dbname' => 'bookstore_midata', 'username' => 'root', 'password' => ''), 'bookstore');
 }