public function connect() { if ($this->_connection) { return; } // parse dsn $config = $this->_config['connection']; $dsn = $this->_config["connection"]["dsn"]; $dsn_temp = explode(':', $dsn); $this->_db_type = $dsn_temp[0]; foreach (explode(';', $dsn_temp[1]) as $row) { $row_temp = explode('=', $row); $config[$row_temp[0]] = $row_temp[1]; } // regist namespace-path mapping to fuel as PSR-0 so Symfony\Finder can't find entities normally. $proxy_dir = APPPATH . "vendor" . DS . "sakuraiyuta" . DS . "fuel-orientdb" . DS . "tmp" . DS; $entity_dir = isset($this->_config["entity_dir"]) ? $this->_config["entity_dir"] : APPPATH . "classes" . DS . "Entity" . DS; \Autoloader::add_namespace("Doctrine", $proxy_dir . DS . "/Doctrine" . DS, TRUE); \Autoloader::add_namespace("Entity", $entity_dir, TRUE); // initialize ODM-Manager $parameters = BindingParameters::create("http://{$config['username']}:{$config['password']}@{$config['host']}:{$config['port']}/{$config['dbname']}"); $binding = new HttpBinding($parameters); $reader = new Reader(new ArrayCache()); $mapper = new Mapper($proxy_dir, $reader); $mapper->setDocumentDirectories(array($entity_dir => "Entity")); $manager = new Manager($mapper, $binding); // Prevent this information from showing up in traces unset($config['username'], $config['password']); $this->_connection = array("manager" => $manager, "binding" => $binding, "mapper" => $mapper); return $this->_connection; }