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 DocumentHandler

A handler that manages documents

A document handler that fetches documents from the server and persists them on the server. It does so by issuing the appropriate HTTP requests to the server.


triagens\ArangoDb\Handler
Extended by triagens\ArangoDb\DocumentHandler

Direct known subclasses

triagens\ArangoDb\EdgeHandler, triagens\ArangoDb\VertexHandler

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

Methods summary

public triagens\ArangoDb\Document
# get( string $collection, mixed $documentId, array $options = [] )

Get a single document from a collection

Get a single document from a collection

Alias method for getById()

Parameters

$collection
  • collection id as a string or number
$documentId
  • document identifier
$options
  • optional, array of options

Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false
  • 'revision' - the documents revision
  • 'ifMatch' - boolean if given revision should match or not
  • Returns

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

    Throws

    triagens\ArangoDb\Exception
    public boolean
    # has( string $collection, mixed $documentId )

    Check if a document exists

    Check if a document exists

    This will call self::get() internally and checks if there was an exception thrown which represents an 404 request.

    Parameters

    $collection
    • collection id as a string or number
    $documentId
    • document identifier

    Returns

    boolean

    Throws

    triagens\ArangoDb\Exception
    When any other error than a 404 occurs
    public triagens\ArangoDb\Document
    # getById( string $collection, mixed $documentId, array $options = [] )

    Get a single document from a collection

    Get a single document from a collection

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

    Parameters

    $collection
    • collection id as a string or number
    $documentId
    • document identifier
    $options
    • optional, array of options

    Options are :

  • '_includeInternals' - true to include the internal attributes. Defaults to false
  • '_ignoreHiddenAttributes' - true to show hidden attributes. Defaults to false
  • 'ifMatch' - boolean if given revision should match or not
  • 'revision' - The document is returned if it matches/not matches revision.
  • Returns

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

    Throws

    triagens\ArangoDb\Exception
    public array
    # getHead( string $collection, mixed $documentId, boolean $revision = null, string $ifMatch = null )

    Gets information about a single documents from a collection

    Gets information about a single documents from a collection

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

    Parameters

    $collection
    • collection id as a string or number.
    $documentId
    • document identifier.
    $revision
    $ifMatch - boolean if given revision should match or not.
    $ifMatch
    $revision - The document is returned if it matches/not matches revision.

    Returns

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

    Throws

    triagens\ArangoDb\Exception
    protected triagens\ArangoDb\Document
    # createFromArrayWithContext( $data, $options )

    Intermediate function to call the createFromArray function from the right context

    Intermediate function to call the createFromArray function from the right context

    Parameters

    $data
    $options

    Returns

    triagens\ArangoDb\Document

    Throws

    triagens\ArangoDb\ClientException
    public mixed
    # store( triagens\ArangoDb\Document $document, mixed $collection = null, array $options = [] )

    Store a document to a collection

    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

    $document
    • the document to be added, can be passed as a document or an array
    $collection
    • collection id as string or number
    $options
    • optional, array of options

    Options are :

  • 'createCollection' - create the collection if it does not yet exist.
  • '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.
  • Returns

    mixed
    • id of document created

    Throws

    triagens\ArangoDb\Exception

    Since

    1.0
    public mixed
    # save( mixed $collection, triagens\ArangoDb\Document|array $document, array $options = [] )

    save a document to a collection

    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

    $collection
    • collection id as string or number
    $document
    • the document to be added, can be passed as a document or an array
    $options
    • optional, array of options

    Options are :

  • 'createCollection' - create the collection if it does not yet exist.
  • '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.
  • Returns

    mixed
    • id of document created

    Throws

    triagens\ArangoDb\Exception

    Since

    1.0
    public boolean
    # update( triagens\ArangoDb\Document $document, array $options = [] )

    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

    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

    $document
    • The patch document that will update the document in question
    $options
    • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • '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)
  • '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
  • Returns

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

    Throws

    triagens\ArangoDb\Exception
    public boolean
    # updateById( string $collection, mixed $documentId, triagens\ArangoDb\Document $document, array $options = [] )

    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

    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

    $collection
    • collection id as string or number
    $documentId
    • document id as string or number
    $document
    • patch document which contains the attributes and values to be updated
    $options
    • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • '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)
  • '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
  • Returns

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

    Throws

    triagens\ArangoDb\Exception
    public boolean
    # replace( triagens\ArangoDb\Document $document, array $options = [] )

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

    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

    $document
    • document to be updated
    $options
    • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • '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
  • Returns

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

    Throws

    triagens\ArangoDb\Exception
    public boolean
    # replaceById( mixed $collection, mixed $documentId, triagens\ArangoDb\Document $document, array $options = [] )

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

    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

    $collection
    • collection id as string or number
    $documentId
    • document id as string or number
    $document
    • document to be updated
    $options
    • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • '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
  • Returns

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

    Throws

    triagens\ArangoDb\Exception
    public boolean
    # remove( triagens\ArangoDb\Document $document, array $options = [] )

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

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

    Parameters

    $document
    • document to be removed
    $options
    • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • '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
  • Returns

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

    Throws

    triagens\ArangoDb\Exception
    public boolean
    # removeById( mixed $collection, mixed $documentId, mixed $revision = null, array $options = [] )

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

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

    Parameters

    $collection
    • collection id as string or number
    $documentId
    • document id as string or number
    $revision
    • optional revision of the document to be deleted
    $options
    • optional, array of options

    Options are :

  • 'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])
  • '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
  • Returns

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

    Throws

    triagens\ArangoDb\Exception
    protected
    # createCollectionIfOptions( $collection, array $options )

    Parameters

    $collection
    collection name or id
    $options
    • optional, array of options

    Options are :

  • 'createCollection' - true to create the collection if it does not exist
  • 'createCollectionType' - "document" or 2 for document collection
  • "edge" or 3 for edge collection
  • Methods inherited from triagens\ArangoDb\Handler

    __construct(), getConnection(), getConnectionOption(), includeOptionsInBody(), includeOptionsInParams(), json_encode_wrapper(), makeCollection()

    Constants summary

    string ENTRY_DOCUMENTS

    documents array index

    documents array index

    # 'documents'
    string OPTION_COLLECTION

    collection parameter

    collection parameter

    # 'collection'
    string OPTION_EXAMPLE

    example parameter

    example parameter

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