Constants

ENTRY_DOCUMENTS

ENTRY_DOCUMENTS

documents array index

OPTION_COLLECTION

OPTION_COLLECTION

collection parameter

OPTION_EXAMPLE

OPTION_EXAMPLE

example parameter

Properties

$_connection

$_connection : 

Connection object

Type

Methods

get()

get(string $collectionId, mixed $documentId, array $options) : \triagens\ArangoDb\Document

Get a single document from a collection

Alias method for getById()

Parameters

string $collectionId
  • collection id as a string or number
mixed $documentId
  • document identifier
array $options
  • optional, array of options
                       <p>Options are :
                       <li>'_includeInternals' - true to include the internal attributes. Defaults to false</li>
                       <li>'includeInternals' - Deprecated, please use '_includeInternals'.</li>
                       <li>'_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false</li>
                       <li>'ignoreHiddenAttributes' - Deprecated, please use '_ignoreHiddenAttributes'.</li>
                       <li>'revision' - the documents revision</li>
                       <li>'ifMatch' - boolean if given revision should match or not</li>
                       </p>

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\Document
  • the document fetched from the server

getById()

getById(string $collectionId, mixed $documentId, array $options) : \triagens\ArangoDb\Document

Get a single document from a collection

This will throw if the document cannot be fetched from the server.

Parameters

string $collectionId
  • collection id as a string or number
mixed $documentId
  • document identifier
array $options
  • optional, array of options
                       <p>Options are :
                       <li>'_includeInternals' - true to include the internal attributes. Defaults to false</li>
                       <li>'includeInternals' - Deprecated, please use '_includeInternals'.</li>
                       <li>'_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false</li>
                       <li>'ignoreHiddenAttributes' - Deprecated, please use '_ignoreHiddenAttributes'.</li>
                       <li>'ifMatch' - boolean if given revision should match or not</li>
                       <li>'revision' - The document is returned if it matches/not matches revision.</li>
                       </p>

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\Document
  • the document fetched from the server

getHead()

getHead(string $collectionId, mixed $documentId,  $revision,  $ifMatch) : array

Gets information about a single documents from a collection

This will throw if the document cannot be fetched from the server

Parameters

string $collectionId
  • collection id as a string or number.
mixed $documentId
  • document identifier.
$revision
$ifMatch

Throws

\triagens\ArangoDb\Exception

Returns

array —
  • an array containing the complete header including the key httpCode.

createFromArrayWithContext()

createFromArrayWithContext( $data,  $options) : \triagens\ArangoDb\Document

Intermediate function to call the createFromArray function from the right context

Parameters

$data
$options

Returns

\triagens\ArangoDb\Document

getAllIds()

getAllIds(mixed $collectionId) : array

Get the list of all documents' ids from a collection

This will throw if the list cannot be fetched from the server

Parameters

mixed $collectionId
  • collection id as string or number

Throws

\triagens\ArangoDb\Exception

Returns

array —
  • ids of documents in the collection

getByExample()

getByExample(mixed $collectionId, mixed $document, boolean|array $options) : \triagens\ArangoDb\cursor

Get document(s) by specifying an example

This will throw if the list cannot be fetched from the server

Parameters

mixed $collectionId
  • collection id as string or number
mixed $document
  • the example document as a Document object or an array
boolean|array $options
  • optional, prior to v1.0.0 this was a boolean value for sanitize, since v1.0.0 it's an array of options.
                            <p>Options are :<br>
                            <li>'_sanitize' - True to remove _id and _rev attributes from result documents. Defaults to false.</li>
                            <li>'sanitize' - Deprecated, please use '_sanitize'.</li>
                            <li>'_hiddenAttributes' - Set an array of hidden attributes for created documents.
                            <li>'hiddenAttributes' - Deprecated, please use '_hiddenAttributes'.</li>
                            <p>
                            This is actually the same as setting hidden attributes using setHiddenAttributes() on a document. <br>
                            The difference is, that if you're returning a resultset of documents, the getAll() is already called <br>
                            and the hidden attributes would not be applied to the attributes.<br>
                            </p>
                            </li>
                            <li>'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch</li>
                            <li>'skip' -  Optional, The number of documents to skip in the query.</li>
                            <li>'limit' -  Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.</li>
                            </p>

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\cursor —
  • Returns a cursor containing the result

add()

add(mixed $collectionId, \triagens\ArangoDb\Document $document, boolean|array $options) : mixed

Add a document to a collection

This will add the document to the collection and return the document's id

This will throw if the document cannot be created

Parameters

mixed $collectionId
  • collection id as string or number
\triagens\ArangoDb\Document $document
  • the document to be added
boolean|array $options
  • optional, prior to v1.2.0 this was a boolean value for create. Since v1.0.0 it's an array of options.
                            <p>Options are :<br>
                            <li>'create' - create the collection if it does not yet exist.</li>
                            <li>'waitForSync' -  if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.</li>
                            </p>

Throws

\triagens\ArangoDb\Exception

Returns

mixed —
  • id of document created

store()

store(\triagens\ArangoDb\Document $document, mixed $collectionId, boolean|array $options) : mixed

Store a document to a collection

This is an alias/shortcut to save() and replace(). Instead of having to determine which of the 3 functions to use, simply pass the document to store() and it will figure out which one to call.

This will throw if the document cannot be saved or replaced.

Parameters

\triagens\ArangoDb\Document $document
  • the document to be added, can be passed as a document or an array
mixed $collectionId
  • collection id as string or number
boolean|array $options
  • optional, prior to v1.2.0 this was a boolean value for create. Since v1.2.0 it's an array of options.
                            <p>Options are :<br>
                            <li>'create' - create the collection if it does not yet exist.</li>
                            <li>'waitForSync' -  if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.</li>
                            </p>

Throws

\triagens\ArangoDb\Exception

Returns

mixed —
  • id of document created

save()

save(mixed $collectionId, mixed $document, boolean|array $options) : mixed

save a document to a collection

This will add the document to the collection and return the document's id

This will throw if the document cannot be saved

Parameters

mixed $collectionId
  • collection id as string or number
mixed $document
  • the document to be added, can be passed as a document or an array
boolean|array $options
  • optional, prior to v1.2.0 this was a boolean value for create. Since v1.0.0 it's an array of options.
                            <p>Options are :<br>
                            <li>'create' - create the collection if it does not yet exist.</li>
                            <li>'waitForSync' -  if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.</li>
                            </p>

Throws

\triagens\ArangoDb\Exception

Returns

mixed —
  • id of document created

update()

update(\triagens\ArangoDb\Document $document, mixed $options) : boolean

Update an existing document in a collection, identified by the including _id and optionally _rev in the patch document.

Attention - The behavior of this method has changed since version 1.1

This will update the document on the server

This will throw if the document cannot be updated

If policy is set to error (locally or globally through the ConnectionOptions) and the passed document has a _rev value set, the database will check that the revision of the document to-be-replaced is the same as the one given.

Parameters

\triagens\ArangoDb\Document $document
  • The patch document that will update the document in question
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                      <p>Options are :
                      <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                      <li>'keepNull' - can be used to instruct ArangoDB to delete existing attributes instead setting their values to null. Defaults to true (keep attributes when set to null)</li>
                      <li>'waitForSync' - can be used to force synchronisation of the document update operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                      </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

updateById()

updateById(string $collectionId, mixed $documentId, \triagens\ArangoDb\Document $document, mixed $options) : boolean

Update an existing document in a collection, identified by collection id and document id Attention - The behavior of this method has changed since version 1.1

This will update the document on the server

This will throw if the document cannot be updated

If policy is set to error (locally or globally through the ConnectionOptions) and the passed document has a _rev value set, the database will check that the revision of the document to-be-updated is the same as the one given.

Parameters

string $collectionId
  • collection id as string or number
mixed $documentId
  • document id as string or number
\triagens\ArangoDb\Document $document
  • patch document which contains the attributes and values to be updated
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                          <p>Options are :
                          <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                          <li>'keepNull' - can be used to instruct ArangoDB to delete existing attributes instead setting their values to null. Defaults to true (keep attributes when set to null)</li>
                          <li>'waitForSync' - can be used to force synchronisation of the document update operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                          </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

replace()

replace(\triagens\ArangoDb\Document $document, mixed $options) : boolean

Replace an existing document in a collection, identified by the document itself

This will update the document on the server

This will throw if the document cannot be updated

If policy is set to error (locally or globally through the ConnectionOptions) and the passed document has a _rev value set, the database will check that the revision of the to-be-replaced document is the same as the one given.

Parameters

\triagens\ArangoDb\Document $document
  • document to be updated
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                      <p>Options are :
                      <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                      <li>'waitForSync' - can be used to force synchronisation of the document update operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                      </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

replaceById()

replaceById(mixed $collectionId, mixed $documentId, \triagens\ArangoDb\Document $document, mixed $options) : boolean

Replace an existing document in a collection, identified by collection id and document id

This will update the document on the server

This will throw if the document cannot be Replaced

If policy is set to error (locally or globally through the ConnectionOptions) and the passed document has a _rev value set, the database will check that the revision of the to-be-replaced document is the same as the one given.

Parameters

mixed $collectionId
  • collection id as string or number
mixed $documentId
  • document id as string or number
\triagens\ArangoDb\Document $document
  • document to be updated
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                          <p>Options are :
                          <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                          <li>'waitForSync' - can be used to force synchronisation of the document replacement operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                          </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

delete()

delete(\triagens\ArangoDb\Document $document, mixed $options) : boolean

Delete a document from a collection, identified by the document itself

Parameters

\triagens\ArangoDb\Document $document
  • document to be updated
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                      <p>Options are :
                      <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                      <li>'waitForSync' - can be used to force synchronisation of the document replacement operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                      </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

remove()

remove(\triagens\ArangoDb\Document $document, mixed $options) : boolean

Remove a document from a collection, identified by the document itself

Parameters

\triagens\ArangoDb\Document $document
  • document to be removed
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                      <p>Options are :
                      <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                      <li>'waitForSync' - can be used to force synchronisation of the document removal operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                      </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

deleteById()

deleteById(string $collectionId, mixed $documentId, mixed $revision, mixed $options) : boolean

Delete a document from a collection, identified by the collection id and document id

Parameters

string $collectionId
  • collection id as string or number
mixed $documentId
  • document id as string or number
mixed $revision
  • optional revision of the document to be deleted
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                        <p>Options are :
                        <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                        <li>'waitForSync' - can be used to force synchronisation of the document replacement operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                        </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

removeById()

removeById(mixed $collectionId, mixed $documentId, mixed $revision, mixed $options) : boolean

Remove a document from a collection, identified by the collection id and document id

Parameters

mixed $collectionId
  • collection id as string or number
mixed $documentId
  • document id as string or number
mixed $revision
  • optional revision of the document to be deleted
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                        <p>Options are :
                        <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                        <li>'waitForSync' - can be used to force synchronisation of the document removal operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                        </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

getDocument()

getDocument(string $url, string $collectionId, mixed $documentId, array $options) : \triagens\ArangoDb\Document

Get a single document (internal method)

This method is the workhorse for getById() in this handler and the edges handler

Parameters

string $url
  • the server-side URL being called
string $collectionId
  • collection id as a string or number
mixed $documentId
  • document identifier
array $options
  • optional, array of options
                       <p>Options are :
                       <li>'_includeInternals' - true to include the internal attributes. Defaults to false</li>
                       <li>'includeInternals' - Deprecated, please use '_includeInternals'.</li>
                       <li>'_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false</li>
                       <li>'ignoreHiddenAttributes' - Deprecated, please use '_ignoreHiddenAttributes'.</li>
                       <li>'ifMatch' - boolean if given revision should match or not</li>
                       <li>'revision' - The document is returned if it matches/not matches revision.</li>
                       </p>

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\Document
  • the document fetched from the server

head()

head(string $url, string $collectionId, mixed $documentId, mixed $revision,  $ifMatch) : array

Get meta-data for a single document (internal method)

This method is the workhorse for getHead() in this handler and the edges handler

Parameters

string $url
  • the server-side URL being called
string $collectionId
  • collection id as a string or number
mixed $documentId
  • document identifier
mixed $revision
  • optional document revision
$ifMatch

Throws

\triagens\ArangoDb\Exception

Returns

array —
  • the document meta-data

patch()

patch(string $url, string $collectionId, mixed $documentId, \triagens\ArangoDb\Document $document, mixed $options) : boolean

Update an existing document in a collection (internal method)

Parameters

string $url
  • server-side URL being called
string $collectionId
  • collection id as string or number
mixed $documentId
  • document id as string or number
\triagens\ArangoDb\Document $document
  • patch document which contains the attributes and values to be updated
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                          <p>Options are :
                          <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                          <li>'keepNull' - can be used to instruct ArangoDB to delete existing attributes instead setting their values to null. Defaults to true (keep attributes when set to null)</li>
                          <li>'waitForSync' - can be used to force synchronisation of the document update operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                          </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

put()

put(string $url, string $collectionId, mixed $documentId, \triagens\ArangoDb\Document $document, mixed $options) : boolean

Replace an existing document in a collection (internal method)

Parameters

string $url
  • the server-side URL being called
string $collectionId
  • collection id as string or number
mixed $documentId
  • document id as string or number
\triagens\ArangoDb\Document $document
  • document to be updated
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                          <p>Options are :
                          <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                          <li>'waitForSync' - can be used to force synchronisation of the document replacement operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                          </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

erase()

erase(string $url, string $collectionId, mixed $documentId, mixed $revision, mixed $options) : boolean

Remove a document from a collection (internal method)

Parameters

string $url
  • the server-side URL being called
string $collectionId
  • collection id as string or number
mixed $documentId
  • document id as string or number
mixed $revision
  • optional revision of the document to be deleted
mixed $options
  • optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
                        <p>Options are :
                        <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
                        <li>'waitForSync' - can be used to force synchronisation of the document removal operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                        </p>

Throws

\triagens\ArangoDb\Exception

Returns

boolean —
  • always true, will throw if there is an error

getConnection()

getConnection() : \triagens\ArangoDb\Connection

Return the connection object

Returns

\triagens\ArangoDb\Connection
  • the connection object

getConnectionOption()

getConnectionOption( $optionName) : mixed

Return a connection option This is a convenience function that calls json_encode_wrapper on the connection

Parameters

$optionName
  • The option to return a value for

Returns

mixed —
  • the option's value

getCursorOptions()

getCursorOptions(mixed $options) : array

Return an array of cursor options

Parameters

mixed $options
  • $options might be a boolean sanitize value, or an array of options, with or without a '_sanitize' key.

Returns

array —
  • array of options

json_encode_wrapper()

json_encode_wrapper(array $body) : string

Return a json encoded string for the array passed.

This is a convenience function that calls json_encode_wrapper on the connection

Parameters

array $body
  • The body to encode into json

Returns

string —
  • json string of the body that was passed

validateAndIncludeOldSingleParameterInParams()

validateAndIncludeOldSingleParameterInParams(array $options, array $params, mixed $parameter) : array

Helper function that validates and includes an old single method parameter setting into the parameters array given.

This is only for keeping backwards-compatibility where methods had for example a parameter which was called 'policy' and which was later changed to being an array of options, so more than one options can be passed easily. This is only for options that are to be sent to the ArangoDB server.

Parameters

array $options
  • The options array that may hold the policy to include in the parameters. If it's not an array, then the value is the policy value.
array $params
  • The parameters into which the options will be included.
mixed $parameter
  • the old single parameter key to use.

Returns

array —

$params - array of parameters for use in a url

includeOptionsInParams()

includeOptionsInParams(array $options, array $params, array $includeArray) : array

Helper function that runs through the options given and includes them into the parameters array given.

Only options that are set in $includeArray will be included. This is only for options that are to be sent to the ArangoDB server in form of url parameters (like 'waitForSync', 'keepNull', etc...) .

Parameters

array $options
  • The options array that holds the options to include in the parameters
array $params
  • The parameters into which the options will be included.
array $includeArray
  • The array that defines which options are allowed to be included, and what their default value is. for example: 'waitForSync'=>true

Returns

array —

$params - array of parameters for use in a url

includeOptionsInBody()

includeOptionsInBody(array $options, array $body, array $includeArray) : array

Helper function that runs through the options given and includes them into the parameters array given.

Only options that are set in $includeArray will be included. This is only for options that are to be sent to the ArangoDB server in a json body(like 'limit', 'skip', etc...) .

Parameters

array $options
  • The options array that holds the options to include in the parameters
array $body
  • The array into which the options will be included.
array $includeArray
  • The array that defines which options are allowed to be included, and what their default value is. for example: 'waitForSync'=>true

Returns

array —

$params - array of parameters for use in a url

getDocumentId()

getDocumentId(mixed $document) : mixed

Helper function to get a document id from a document or a document id value

Parameters

mixed $document
  • document id OR document to be updated

Throws

\triagens\ArangoDb\ClientException

Returns

mixed —
  • document id, will throw if there is an error

getRevision()

getRevision(mixed $document) : mixed

Helper function to get a document id from a document or a document id value

Parameters

mixed $document
  • document id OR document to be updated

Throws

\triagens\ArangoDb\ClientException

Returns

mixed —
  • document id, will throw if there is an error

getCollectionId()

getCollectionId(\triagens\ArangoDb\Document $document) : mixed

Helper function to get a collection id from a document

Parameters

\triagens\ArangoDb\Document $document
  • document id

Throws

\triagens\ArangoDb\ClientException

Returns

mixed —
  • collection id, will throw if there is an error