Example #1
0
 /**
  * Returns the execution plan for a query. This will not execute the query.
  * @param  string         $query      The AQL query to run.
  * @param  array          $parameters An optional associative array containing parameters to bind to the query.
  * @throws QueryException
  * @return array
  */
 public function explain($query, array $parameters = array())
 {
     $data = array('query' => $query, 'bindVars' => $parameters);
     $statement = new Statement($this->_toolbox->getConnection(), $data);
     try {
         $result = $statement->explain();
         return $result['plan'];
     } catch (\Exception $e) {
         $normalised = $this->_toolbox->normaliseDriverExceptions($e);
         throw new QueryException($normalised['message'], $normalised['code']);
     }
 }
Example #2
0
 /**
  * List the AQL functions registered on the server and optionally, filter by namespace.
  * @param  string          $namespace The optional namespace to filter the list of AQL functions on.
  * @throws ServerException
  */
 public function listAQLFunctions($namespace = null)
 {
     try {
         $userFunction = new AqlUserFunction($this->_toolbox->getConnection());
         $functions = $userFunction->getRegisteredUserFunctions($namespace);
         $result = array();
         foreach ($functions as $function) {
             $result[$function['name']] = $function['code'];
         }
         return $result;
     } catch (\Exception $e) {
         $normalised = $this->_toolbox->normaliseDriverExceptions($e);
         throw new ServerException($normalised['message'], $normalised['code']);
     }
 }
Example #3
0
 /**
  * Get a cloned connection with targetting a database.
  * @param  string                        $database The optional name of the database. Defaults to _system.
  * @return \triagens\ArangoDb\Connection
  */
 private function getConnection($database = '_system')
 {
     $connection = clone $this->_toolbox->getConnection();
     $connection->setDatabase($database);
     return $connection;
 }
Example #4
0
 /**
  * @covers Paradox\Toolbox::getConnection
  */
 public function testGetConnection()
 {
     $connection = $this->toolbox->getConnection();
     $this->assertInstanceOf('triagens\\ArangoDb\\Connection', $connection, 'getConnection() did not return a triagens\\ArangoDb\\Connection');
 }