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 Document

Value object representing a single collection-based document


Direct known subclasses

triagens\ArangoDb\Edge, triagens\ArangoDb\Graph, triagens\ArangoDb\User, triagens\ArangoDb\Vertex

Namespace: triagens\ArangoDb
Package: triagens\ArangoDb
Since: 0.2
Located at Document.php

Methods summary

public
# __construct( array $options = null )

Constructs an empty document

Constructs an empty document

Parameters

$options
  • optional, initial $options for document

<

p>Options are :

  • '_hiddenAttributes' - Set an array of hidden attributes for created documents.
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false
  • public static triagens\ArangoDb\Document|triagens\ArangoDb\Edge|triagens\ArangoDb\Graph
    # createFromArray( array $values, array $options = [] )

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

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

    Parameters

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

    Returns

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

    Throws

    triagens\ArangoDb\ClientException
    public
    # __clone( )

    Clone a document

    Clone a document

    Returns the clone

    Magic

    public string
    # __toString( )

    Get a string representation of the document.

    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

    Magic

    public string
    # toJson( array $options = [] )

    Returns the document as JSON-encoded string

    Returns the document as JSON-encoded string

    Parameters

    $options
    • optional, array of options that will be passed to the getAll function

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false
  • Returns

    string
    • JSON-encoded document
    public string
    # toSerialized( array $options = [] )

    Returns the document as a serialized string

    Returns the document as a serialized string

    Parameters

    $options
    • optional, array of options that will be passed to the getAll function

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false
  • Returns

    string
    • PHP serialized document
    public array
    # filterHiddenAttributes( array $attributes, array $_hiddenAttributes = [] )

    Returns the attributes with the hidden ones removed

    Returns the attributes with the hidden ones removed

    Parameters

    $attributes
    • attributes array
    $_hiddenAttributes

    Returns

    array
    • attributes array
    public
    # set( string $key, mixed $value )

    Set a document attribute

    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

    $key
    • attribute name
    $value
    • value for attribute

    Throws

    triagens\ArangoDb\ClientException
    public
    # __set( string $key, mixed $value )

    Set a document attribute, magic method

    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

    $key
    • attribute name
    $value
    • value for attribute

    Throws

    triagens\ArangoDb\ClientException

    Magic

    public mixed
    # get( string $key )

    Get a document attribute

    Get a document attribute

    Parameters

    $key
    • name of attribute

    Returns

    mixed
    • value of attribute, NULL if attribute is not set
    public mixed
    # __get( string $key )

    Get a document attribute, magic method

    Get a document attribute, magic method

    This function is mapped to get() internally.

    Parameters

    $key
    • name of attribute

    Returns

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

    Magic

    public boolean
    # __isset( string $key )

    Is triggered by calling isset() or empty() on inaccessible properties.

    Is triggered by calling isset() or empty() on inaccessible properties.

    Parameters

    $key
    • name of attribute

    Returns

    boolean
    returns true or false (set or not set)
    public
    # __unset( $key )

    Magic method to unset an attribute. Caution!!! This works only on the first array level. The preferred method to unset attributes in the database, is to set those to null and do an update() with the option: 'keepNull' => false.

    Magic method to unset an attribute. Caution!!! This works only on the first array level. The preferred method to unset attributes in the database, is to set those to null and do an update() with the option: 'keepNull' => false.

    Parameters

    $key

    Magic

    public array
    # getAll( array $options = [] )

    Get all document attributes

    Get all document attributes

    Parameters

    $options
    • optional, array of options for the getAll function, or the boolean value for $includeInternals

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false
  • Returns

    array
    • array of all document attributes/values
    public mixed
    # getAllForInsertUpdate( )

    Get all document attributes for insertion/update

    Get all document attributes for insertion/update

    Returns

    mixed
    • associative array of all document attributes/values
    public mixed
    # getAllAsObject( array $options = [] )

    Get all document attributes, and return an empty object if the documentapped into a DocumentWrapper class

    Get all document attributes, and return an empty object if the documentapped into a DocumentWrapper class

    Parameters

    $options
    • optional, array of options for the getAll function, or the boolean value for $includeInternals

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false
  • Returns

    mixed
    • associative array of all document attributes/values, or an empty StdClass if the document does not have any
    public
    # setHiddenAttributes( array $attributes )

    Set the hidden attributes $cursor

    Set the hidden attributes $cursor

    Parameters

    $attributes
    • array of attributes
    public array
    # getHiddenAttributes( )

    Get the hidden attributes

    Get the hidden attributes

    Returns

    array
    $attributes - array of attributes
    public boolean
    # isIgnoreHiddenAttributes( )

    Returns

    boolean
    public
    # setIgnoreHiddenAttributes( boolean $ignoreHiddenAttributes )

    Parameters

    $ignoreHiddenAttributes
    public boolean
    # setChanged( boolean $value )

    Set the changed flag

    Set the changed flag

    Parameters

    $value
    • change flag

    Returns

    boolean
    public boolean
    # getChanged( )

    Get the changed flag

    Get the changed flag

    Returns

    boolean
    • true if document was changed, false otherwise
    public
    # setIsNew( boolean $isNew )

    Set the isNew flag

    Set the isNew flag

    Parameters

    $isNew
    • flags if new or existing doc
    public boolean
    # getIsNew( )

    Get the isNew flag

    Get the isNew flag

    Returns

    boolean
    $isNew - flags if new or existing doc
    public
    # setInternalId( string $id )

    Set the internal document id

    Set the internal document id

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

    Parameters

    $id
    • internal document id

    Throws

    triagens\ArangoDb\ClientException
    public
    # setInternalKey( string $key )

    Set the internal document key

    Set the internal document key

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

    Parameters

    $key
    • internal document key

    Throws

    triagens\ArangoDb\ClientException
    public string
    # getInternalId( )

    Get the internal document id (if already known)

    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
    public string
    # getInternalKey( )

    Get the internal document key (if already known)

    Get the internal document key (if already known)

    Returns

    string
    • internal document key, might be NULL if document does not yet have a key
    public string
    # getHandle( )

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

    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
    public mixed
    # getId( )

    Get the document id (if already known)

    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
    public mixed
    # getKey( )

    Get the document key (if already known). Alias function for getInternalKey()

    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
    public mixed
    # getCollectionId( )

    Get the collection id (if already known)

    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
    public
    # setRevision( mixed $rev )

    Set the document revision

    Set the document revision

    Revision ids are generated on the server only.

    Document ids are strings, even if they look "numeric" To reliably store a document id elsewhere, a PHP string must be used

    Parameters

    $rev
    • revision id
    public mixed
    # getRevision( )

    Get the document revision (if already known)

    Get the document revision (if already known)

    Returns

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

    Constants summary

    string ENTRY_ID

    Document id index

    Document id index

    # '_id'
    string ENTRY_KEY

    Document key index

    Document key index

    # '_key'
    string ENTRY_REV

    Revision id index

    Revision id index

    # '_rev'
    string ENTRY_ISNEW

    isNew id index

    isNew id index

    # '_isNew'
    string ENTRY_HIDDENATTRIBUTES

    hidden attribute index

    hidden attribute index

    # '_hiddenAttributes'
    string ENTRY_IGNOREHIDDENATTRIBUTES

    hidden attribute index

    hidden attribute index

    # '_ignoreHiddenAttributes'
    string OPTION_WAIT_FOR_SYNC

    waitForSync option index

    waitForSync option index

    # 'waitForSync'
    string OPTION_POLICY

    policy option index

    policy option index

    # 'policy'
    string OPTION_KEEPNULL

    keepNull option index

    keepNull option index

    # 'keepNull'

    Properties summary

    protected string $_id

    The document id (might be NULL for new documents)

    The document id (might be NULL for new documents)

    #
    protected string $_key

    The document key (might be NULL for new documents)

    The document key (might be NULL for new documents)

    #
    protected mixed $_rev

    The document revision (might be NULL for new documents)

    The document revision (might be NULL for new documents)

    #
    protected array $_values

    The document attributes (names/values)

    The document attributes (names/values)

    # []
    protected boolean $_changed

    Flag to indicate whether document was changed locally

    Flag to indicate whether document was changed locally

    # false
    protected boolean $_isNew

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

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

    # true
    protected boolean $_doValidate

    Flag to indicate whether validation of document values should be performed This can be turned on, but has a performance penalty

    Flag to indicate whether validation of document values should be performed This can be turned on, but has a performance penalty

    # false
    protected boolean $_hiddenAttributes

    Flag to indicate whether document was changed locally

    Flag to indicate whether document was changed locally

    # []
    protected boolean $_ignoreHiddenAttributes

    Flag to indicate whether document was changed locally

    Flag to indicate whether document was changed locally

    # false
    ArangoDB-PHP API Documentation API documentation generated by ApiGen