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); }
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; }
public function adapter() { return Adapter::factory('mysql', array('adapter' => 'mysql', 'host' => 'localhost', 'dbname' => 'bookstore_midata', 'username' => 'root', 'password' => ''), 'bookstore'); }