ArangoDB-PHP API Documentation
  • Namespace
  • Class
  • Deprecated

Namespaces

  • triagens
    • ArangoDb

Classes

  • AdminHandler
  • AqlUserFunction
  • Autoloader
  • Batch
  • BatchPart
  • BindVars
  • Collection
  • CollectionHandler
  • Connection
  • ConnectionOptions
  • Cursor
  • Database
  • DefaultValues
  • Document
  • DocumentHandler
  • Edge
  • EdgeDefinition
  • EdgeHandler
  • Endpoint
  • Export
  • ExportCursor
  • Graph
  • GraphHandler
  • Handler
  • HttpHelper
  • HttpResponse
  • QueryCacheHandler
  • QueryHandler
  • Statement
  • TraceRequest
  • TraceResponse
  • Transaction
  • Traversal
  • UpdatePolicy
  • UrlHelper
  • Urls
  • User
  • UserHandler
  • ValueValidator
  • Vertex
  • VertexHandler

Exceptions

  • ClientException
  • ConnectException
  • Exception
  • ServerException

Class Statement

Container for an AQL query

Optional bind parameters can be used when issuing the AQL query to separate the query from the values. Executing a query will result in a cursor being created.

There is an important distinction between two different types of statements:

  • statements that produce an array of documents as their result AND
  • statements that do not produce documents

For example, a statement such as "FOR e IN example RETURN e" will produce an array of documents as its result. The result can be treated as an array of documents, and each document can be updated and sent back to the server by the client.

However, the query "RETURN 1 + 1" will not produce an array of documents as its result, but an array with a single scalar value (the number 2). "2" is not a valid document so creating a document from it will fail.

To turn the results of this query into a document, the following needs to be done:

  • modify the query to "RETURN { value: 1 + 1 }". The result will then be a an array of documents with a "value" attribute
  • use the "_flat" option for the statement to indicate that you don't want to treat the statement result as an array of documents, but as a flat array
Namespace: triagens\ArangoDb
Package: triagens\ArangoDb
Since: 0.2
Located at Statement.php

Methods summary

public
# __construct( triagens\ArangoDb\Connection $connection, array $data )

Initialise the statement

Initialise the statement

The $data property can be used to specify the query text and further options for the query.

An important consideration when creating a statement is whether the statement will produce a list of documents as its result or any other non-document value. When a statement is created, by default it is assumed that the statement will produce documents. If this is not the case, executing a statement that returns non-documents will fail.

To explicitly mark the statement as returning non-documents, the '_flat' option should be specified in $data.

Parameters

$connection
  • the connection to be used
$data
  • statement initialization data

Throws

triagens\ArangoDb\Exception
protected triagens\ArangoDb\Connection
# getConnection( )

Return the connection object

Return the connection object

Returns

triagens\ArangoDb\Connection
  • the connection object
public triagens\ArangoDb\Cursor
# execute( )

Execute the statement

Execute the statement

This will post the query to the server and return the results as a Cursor. The cursor can then be used to iterate the results.

Returns

triagens\ArangoDb\Cursor

Throws

triagens\ArangoDb\Exception
public array
# explain( )

Explain the statement's execution plan

Explain the statement's execution plan

This will post the query to the server and return the execution plan as an array.

Returns

array

Throws

triagens\ArangoDb\Exception
public array
# validate( )

Validates the statement

Validates the statement

This will post the query to the server for validation and return the validation result as an array.

Returns

array

Throws

triagens\ArangoDb\Exception
public triagens\ArangoDb\Cursor
# __invoke( mixed $args )

Invoke the statement

Invoke the statement

This will simply call execute(). Arguments are ignored.

Parameters

$args
  • arguments for invocation, will be ignored

Returns

triagens\ArangoDb\Cursor
  • the result cursor

Throws

triagens\ArangoDb\Exception
public string
# __toString( )

Return a string representation of the statement

Return a string representation of the statement

Returns

string
  • the current query string
public
# bind( mixed $key, mixed $value = null )

Bind a parameter to the statement

Bind a parameter to the statement

This method can either be called with a string $key and a separate value in $value, or with an array of all bind bind parameters in $key, with $value being NULL.

Allowed value types for bind parameters are string, int, double, bool and array. Arrays must not contain any other than these types.

Parameters

$key
  • name of bind variable OR an array of all bind variables
$value
  • value for bind variable

Throws

triagens\ArangoDb\Exception
public array
# getBindVars( )

Get all bind parameters as an array

Get all bind parameters as an array

Returns

array
  • array of bind variables/values
public
# setQuery( string $query )

Set the query string

Set the query string

Parameters

$query
  • query string

Throws

triagens\ArangoDb\ClientException
public string
# getQuery( )

Get the query string

Get the query string

Returns

string
  • current query string value
public string
# setResultType( $resultType )

setResultType

setResultType

Parameters

$resultType

Returns

string
  • resultType of the query
public
# setCount( boolean $value )

Set the count option for the statement

Set the count option for the statement

Parameters

$value
  • value for count option
public boolean
# getCount( )

Get the count option value of the statement

Get the count option value of the statement

Returns

boolean
  • current value of count option
public
# setFullCount( boolean $value )

Set the full count option for the statement

Set the full count option for the statement

Parameters

$value
  • value for full count option
public boolean
# getFullCount( )

Get the full count option value of the statement

Get the full count option value of the statement

Returns

boolean
  • current value of full count option
public
# setCache( boolean $value )

Set the caching option for the statement

Set the caching option for the statement

Parameters

$value
  • value for 'cache' option
public boolean
# getCache( )

Get the caching option value of the statement

Get the caching option value of the statement

Returns

boolean
  • current value of 'cache' option
public
# setBatchSize( integer $value )

Set the batch size for the statement

Set the batch size for the statement

The batch size is the number of results to be transferred in one server round-trip. If a query produces more results than the batch size, it creates a server-side cursor that provides the additional results.

The server-side cursor can be accessed by the client with subsequent HTTP requests.

Parameters

$value
  • batch size value

Throws

triagens\ArangoDb\ClientException
public integer
# getBatchSize( )

Get the batch size for the statement

Get the batch size for the statement

Returns

integer
  • current batch size value

Constants summary

string ENTRY_QUERY

Query string index

Query string index

# 'query'
string ENTRY_COUNT

Count option index

Count option index

# 'count'
string ENTRY_BATCHSIZE

Batch size index

Batch size index

# 'batchSize'
string ENTRY_RETRIES

Retries index

Retries index

# 'retries'
string ENTRY_BINDVARS

Bind variables index

Bind variables index

# 'bindVars'
string FULL_COUNT

Full count option index

Full count option index

# 'fullCount'
ArangoDB-PHP API Documentation API documentation generated by ApiGen