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; }
<?php use Doctrine\OrientDB\Binding\HttpBinding; use Doctrine\OrientDB\Binding\BindingParameters; require __DIR__ . '/../autoload.php'; $parameters = BindingParameters::create('http://*****:*****@127.0.0.1:2480/friends'); $binding = new HttpBinding($parameters); $friends = $binding->query('select from friends where any() traverse(0,1) ( @rid = #5:3 ) and @rid <> #5:3'); foreach ($friends as $friend) { echo $friend->name, "\n"; }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid parameters type */ public function testParametersCreateAcceptsOnlyStringsOrArrays() { $this->assertInstanceOf('Doctrine\\OrientDB\\Binding\\BindingParameters', BindingParameters::create(array())); $this->assertInstanceOf('Doctrine\\OrientDB\\Binding\\BindingParameters', BindingParameters::create('')); BindingParameters::create((object) array()); }
/** * Creates the HttpBinding connection instance. * This method is called by [[open]] to establish a DB connection. * The default implementation will create a HttpBinding instance. * You may override this method if the default HttpBinding needs to be adapted for certain DBMS. * @return HttpBinding the pdo instance */ public function createHttpBindingInstance() { $fromUri = BindingParameters::create($this->uri); return new HttpBinding(BindingParameters::create(['host' => $fromUri->getHost(), 'port' => $fromUri->getPort(), 'database' => $fromUri->getDatabase(), 'username' => $this->username, 'password' => $this->password])); }