Example #1
0
 /**
  * Executes a Query or read command
  *
  * @param CommandInterface|BaseBuilder $query
  * @return Response
  * @throws \Exception
  * @throws \brightzone\rexpro\ServerException
  */
 public function executeReadCommand($query)
 {
     if ($query instanceof BaseBuilder) {
         throw new NotSupportedException("There are currently no processors for gremlin/cypher.");
     } elseif (!$this->isSupportedLanguage($query->getScriptLanguage())) {
         throw new NotSupportedException(__CLASS__ . " does not support " . $query->getScriptLanguage());
     }
     try {
         $response = $this->client->send($query->getScript());
     } catch (\Exception $e) {
         //Check for empty return error from server.
         if ($e instanceof \brightzone\rexpro\ServerException && $e->getCode() == 204) {
             $response = [];
         } else {
             throw $e;
         }
     }
     return new Response(['_raw' => $response, '_driver' => $this]);
 }
Example #2
0
 /**
  * An an `update` clause to the current command bag
  * @param null $property
  * @param null $value
  * @return $this
  */
 public function update($property = null, $value = null)
 {
     //The is one situation in which we will want to reformat
     // Or, We're adding a single bit of data as well
     if (!is_null($value)) {
         return parent::update([$property => $value]);
     }
     return parent::update($property);
 }
Example #3
0
 /**
  * Executes a write command
  *
  * These are the "CUD" in CRUD
  *
  * @param CommandInterface|BaseBuilder $command
  * @return Response|null values for some write commands
  */
 public function executeWriteCommand($command)
 {
     if ($this->inTransaction) {
         $this->addTransactionStatement($command->getScript());
         return null;
     }
     /* ToDo: DELETE is very sloppy */
     /* DELETE VERTEX returns an int. DELETE returns either int or before Record */
     /* Drivers expect an empty array upon successful delete */
     /* This needs to be reconciled in a better way */
     $response = $this->executeCommand($command, 'command');
     if (strpos(strtolower($command->getScript()), "delete") === 0) {
         return new Response(['_raw' => [], '_driver' => $this]);
     }
     return $response;
 }