Constants

ENTRY_ID

ENTRY_ID

Document id index

ENTRY_KEY

ENTRY_KEY

Document key index

ENTRY_REV

ENTRY_REV

Revision id index

ENTRY_ISNEW

ENTRY_ISNEW

isNew id index

ENTRY_HIDDEN

ENTRY_HIDDEN

hidden attribute index

OPTION_WAIT_FOR_SYNC

OPTION_WAIT_FOR_SYNC

waitForSync option index

OPTION_POLICY

OPTION_POLICY

policy option index

OPTION_KEEPNULL

OPTION_KEEPNULL

keepNull option index

ENTRY_FROM

ENTRY_FROM

Document _from index

ENTRY_TO

ENTRY_TO

Revision _to index

Properties

$_id

$_id : string

The document id (might be NULL for new documents)

Type

string — - document id

$_key

$_key : string

The document key (might be NULL for new documents)

Type

string — - document id

$_rev

$_rev : mixed

The document revision (might be NULL for new documents)

Type

mixed

$_values

$_values : array

The document attributes (names/values)

Type

array

$_changed

$_changed : boolean

Flag to indicate whether document was changed locally

Type

boolean

$_isNew

$_isNew : boolean

Flag to indicate whether document is a new document (never been saved to the server)

Type

boolean

$_hidden

$_hidden : boolean

Flag to indicate whether document was changed locally

Type

boolean

$_from

$_from : mixed

The edge's from (might be NULL for new documents)

Type

mixed

$_to

$_to : mixed

The edge's to (might be NULL for new documents)

Type

mixed

Methods

__construct()

__construct(array $options) : \triagens\ArangoDb\Document

Constructs an empty document

Parameters

array $options
  • optional, initial $options for document

Returns

\triagens\ArangoDb\Document

createFromArray()

createFromArray(array $values, array $options) : \triagens\ArangoDb\Document|\triagens\ArangoDb\Edge

Factory method to construct a new document using the values passed to populate it

Parameters

array $values
  • initial values for document
array $options
  • optional, initial options for document

Throws

\triagens\ArangoDb\ClientException

Returns

\triagens\ArangoDb\Document|\triagens\ArangoDb\Edge

__clone()

__clone() : void

Clone a document

Returns the clone

__toString()

__toString() : string

Get a string representation of the document.

It will not output hidden attributes.

Returns the document as JSON-encoded string

Returns

string —
  • JSON-encoded document

toJson()

toJson(array $options) : string

Returns the document as JSON-encoded string

Parameters

array $options
  • optional, array of options that will be passed to the getAll function
                  <p>Options are :
                  <li>'_includeInternals' - true to include the internal attributes. Defaults to false</li>
                  <li>'_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false</li>
                  </p>

Returns

string —
  • JSON-encoded document

toSerialized()

toSerialized(array $options) : string

Returns the document as a serialized string

Parameters

array $options
  • optional, array of options that will be passed to the getAll function
                  <p>Options are :
                  <li>'_includeInternals' - true to include the internal attributes. Defaults to false</li>
                  <li>'_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false</li>
                  </p>

Returns

string —
  • PHP serialized document

filterHiddenAttributes()

filterHiddenAttributes(array $attributes) : array

Returns the attributes with the hidden ones removed

Parameters

array $attributes
  • attributes array

Returns

array —
  • attributes array

set()

set(string $key, mixed $value) : void

Set a document attribute

The key (attribute name) must be a string.

This will validate the value of the attribute and might throw an exception if the value is invalid.

Parameters

string $key
  • attribute name
mixed $value
  • value for attribute

Throws

\triagens\ArangoDb\ClientException

__set()

__set(string $key, mixed $value) : void

Set a document attribute, magic method

This is a magic method that allows the object to be used without declaring all document attributes first. This function is mapped to set() internally.

Parameters

string $key
  • attribute name
mixed $value
  • value for attribute

Throws

\triagens\ArangoDb\ClientException

get()

get(string $key) : mixed

Get a document attribute

Parameters

string $key
  • name of attribute

Returns

mixed —
  • value of attribute, NULL if attribute is not set

__get()

__get(string $key) : mixed

Get a document attribute, magic method

This function is mapped to get() internally.

Parameters

string $key
  • name of attribute

Returns

mixed —
  • value of attribute, NULL if attribute is not set

getAll()

getAll(mixed $options) : array

Get all document attributes

Parameters

mixed $options
  • optional, array of options for the getAll function, or the boolean value for $includeInternals
                  <p>Options are :
                  <li>'_includeInternals' - true to include the internal attributes. Defaults to false</li>
                  <li>'_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false</li>
                  </p>

Returns

array —
  • array of all document attributes/values

setHiddenAttributes()

setHiddenAttributes(array $attributes) : void

Set the hidden attributes

Parameters

array $attributes
  • array of attributes

getHiddenAttributes()

getHiddenAttributes() : array

Get the hidden attributes

Returns

array —

$attributes - array of attributes

setChanged()

setChanged(boolean $value) : boolean

Set the changed flag

Parameters

boolean $value
  • change flag

Returns

boolean

getChanged()

getChanged() : boolean

Get the changed flag

Returns

boolean —
  • true if document was changed, false otherwise

setIsNew()

setIsNew(boolean $isNew) : void

Set the isNew flag

Parameters

boolean $isNew
  • flags if new or existing doc

getIsNew()

getIsNew() : boolean

Get the isNew flag

Returns

boolean —

$isNew - flags if new or existing doc

setInternalId()

setInternalId(string $id) : void

Set the internal document id

This will throw if the id of an existing document gets updated to some other id

Parameters

string $id
  • internal document id

Throws

\triagens\ArangoDb\ClientException

setInternalKey()

setInternalKey(string $key) : void

Set the internal document key

This will throw if the key of an existing document gets updated to some other key

Parameters

string $key
  • internal document key

Throws

\triagens\ArangoDb\ClientException

getInternalId()

getInternalId() : string

Get the internal document id (if already known)

Document ids are generated on the server only. Document ids consist of collection id and document id, in the format collectionId/documentId

Returns

string —
  • internal document id, might be NULL if document does not yet have an id

getInternalKey()

getInternalKey() : string

Get the internal document key (if already known)

Returns

string —
  • internal document key, might be NULL if document does not yet have a key

getHandle()

getHandle() : string

Convenience function to get the document handle (if already known) - is an alias to getInternalId()

Document handles are generated on the server only. Document handles consist of collection id and document id, in the format collectionId/documentId

Returns

string —
  • internal document id, might be NULL if document does not yet have an id

getId()

getId() : mixed

Get the document id (if already known)

Document ids are generated on the server only. Document ids are numeric but might be bigger than PHP_INT_MAX. To reliably store a document id elsewhere, a PHP string should be used

Returns

mixed —
  • document id, might be NULL if document does not yet have an id

getKey()

getKey() : mixed

Get the document key (if already known).

Alias function for getInternalKey()

Returns

mixed —
  • document key, might be NULL if document does not yet have a key

getCollectionId()

getCollectionId() : mixed

Get the collection id (if already known)

Collection ids are generated on the server only. Collection ids are numeric but might be bigger than PHP_INT_MAX. To reliably store a collection id elsewhere, a PHP string should be used

Returns

mixed —
  • collection id, might be NULL if document does not yet have an id

setRevision()

setRevision(mixed $rev) : void

Set the document revision

Revision ids are generated on the server only.

Document ids are numeric but might be bigger than PHP_INT_MAX. To reliably store a document id elsewhere, a PHP string should be used

Parameters

mixed $rev
  • revision id

getRevision()

getRevision() : mixed

Get the document revision (if already known)

Returns

mixed —
  • revision id, might be NULL if document does not yet have an id

getFrom()

getFrom() : mixed

Get the 'from' vertex document-handler (if already known)

Returns

mixed —
  • document-handler

getTo()

getTo() : mixed

Get the 'to' vertex document-handler (if already known)

Returns

mixed —
  • document-handler

setFrom()

setFrom(mixed $from) : \triagens\ArangoDb\Edge

Set the 'from' vertex document-handler

Parameters

mixed $from
  • from vertex

Returns

\triagens\ArangoDb\Edge
  • edge object

setTo()

setTo(mixed $to) : \triagens\ArangoDb\Edge

Set the 'to' vertex document-handler

Parameters

mixed $to
  • to vertex

Returns

\triagens\ArangoDb\Edge
  • edge object