/** * 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]); }
/** * 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; }