/**
  * Create a new Orientdb client
  *
  * @return
  */
 public function createConnection()
 {
     // below code is used to create connection usinf Orientdb
     $client = new OriClient($this->getHost(), $this->getPort(), $this->getDatabase());
     $client->getTransport()->setAuth($this->getUsername(), $this->getPassword());
     return $client;
 }
Beispiel #2
0
 /**
  * Proxy creation to a cypher query that does what we want
  *
  * @param Client   $client
  * @param Node     $node
  * @param array    $labels
  * @param boolean  $remove
  */
 public function __construct(Client $client, Node $node, $labels, $remove = false)
 {
     if (!$client->hasCapability(Client::CapabilityLabel)) {
         throw new \RuntimeException('The connected Neo4j version does not have label capability');
     }
     $nodeId = $node->getId();
     if (!is_numeric($nodeId)) {
         throw new \InvalidArgumentException("Cannot set labels on an unsaved node");
     }
     if (!$labels) {
         throw new \InvalidArgumentException("No labels given to set on node");
     }
     $labelSet = implode(':', array_map(function ($label) {
         if (!$label instanceof Label) {
             throw new \InvalidArgumentException("Cannot set a non-label");
         }
         $name = str_replace('`', '``', $label->getName());
         return "`{$name}`";
     }, $labels));
     $setCommand = $remove ? 'REMOVE' : 'SET';
     $query = "START n=node({nodeId}) {$setCommand} n:{$labelSet} RETURN labels(n) AS labels";
     $params = array('nodeId' => $nodeId);
     $cypher = new Query($client, $query, $params);
     parent::__construct($client, $cypher);
 }
Beispiel #3
0
 /**
  * Create a new Orientdb client
  *
  * @return
  */
 public function createConnection()
 {
     //exit('testing');
     /*
             // below code is used to create connection usinf Orientdb-odm
             $parameters = BindingParameters::create($this->config);
             $orient = new Binding($parameters);
             return $orient;
     */
     $client = new OriClient($this->getHost(), $this->getPort(), $this->getDatabase());
     $client->getTransport()->setAuth($this->getUsername(), $this->getPassword());
     return $client;
 }