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 GraphHandler

A handler that manages graphs.

triagens\ArangoDb\Handler
Extended by triagens\ArangoDb\GraphHandler
Namespace: triagens\ArangoDb
Package: triagens\ArangoDb
Since: 1.2
Located at GraphHandler.php

Methods summary

public array
# createGraph( triagens\ArangoDb\Graph $graph )

Create a graph

Create a graph

This will create a graph using the given graph object and return an array of the created graph object's attributes.

Parameters

$graph
  • The graph object which holds the information of the graph to be created

Returns

array

Throws

triagens\ArangoDb\Exception

Since

1.2
public triagens\ArangoDb\Graph|false
# getGraph( String $graph, array $options = [] )

Get a graph

Get a graph

This will get a graph.

Parameters

$graph
  • The name of the graph
$options
  • Options to pass to the method

Returns

triagens\ArangoDb\Graph|false

Throws

triagens\ArangoDb\ClientException

Since

1.2
public
# setBatchsize( integer $batchsize )

Sets the batchsize for any method creating a cursor. Will be reset after the cursor has been created.

Sets the batchsize for any method creating a cursor. Will be reset after the cursor has been created.

Parameters

$batchsize
public
# setCount( integer $count )

Sets the count for any method creating a cursor. Will be reset after the cursor has been created.

Sets the count for any method creating a cursor. Will be reset after the cursor has been created.

Parameters

$count
public
# setLimit( integer $limit )

Sets the limit for any method creating a cursor. Will be reset after the cursor has been created.

Sets the limit for any method creating a cursor. Will be reset after the cursor has been created.

Parameters

$limit
public boolean
# properties( mixed $graph )

Get a graph's properties

Get a graph's properties

Parameters

$graph
  • graph name as a string or instance of Graph

Returns

boolean
  • Returns an array of attributes. Will throw if there is an error

Throws

triagens\ArangoDb\Exception

Since

1.2
public boolean
# dropGraph( mixed $graph, boolean $dropCollections = true )

Drop a graph and remove all its vertices and edges, also drops vertex and edge collections

Drop a graph and remove all its vertices and edges, also drops vertex and edge collections

Parameters

$graph
  • graph name as a string or instance of Graph
$dropCollections
  • if set to false the graphs collections will not be droped.

Returns

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

Throws

triagens\ArangoDb\Exception

Since

1.2
public triagens\ArangoDb\Graph
# addOrphanCollection( mixed $graph, string $orphanCollection )

add an orphan collection to the graph.

add an orphan collection to the graph.

This will add a further orphan collection to the graph.

Parameters

$graph
  • graph name as a string or instance of Graph
$orphanCollection
  • the orphan collection to be added as string.

Returns

triagens\ArangoDb\Graph

Throws

triagens\ArangoDb\Exception

Since

2.2
public triagens\ArangoDb\Graph
# deleteOrphanCollection( mixed $graph, string $orphanCollection, boolean $dropCollection = false )

deletes an orphan collection from the graph.

deletes an orphan collection from the graph.

This will delete an orphan collection from the graph.

Parameters

$graph
  • graph name as a string or instance of Graph
$orphanCollection
  • the orphan collection to be removed as string.
$dropCollection
  • if set to true the collection is deleted, not just removed from the graph.

Returns

triagens\ArangoDb\Graph

Throws

triagens\ArangoDb\Exception

Since

2.2
public array
# getVertexCollections( mixed $graph, array $options = [] )

gets all vertex collection from the graph.

gets all vertex collection from the graph.

This will get all vertex collection (orphans and used in edge definitions) from the graph.

If this method or any method that calls this method is used in batch mode and caching is off,
then for each call, this method will make an out of batch API call to the db in order to get the appropriate collections.

If caching is on, then the GraphHandler will only call the DB API once for the chosen graph, and return data from cache for the following calls.

Parameters

$graph
  • graph name as a string or instance of Graph
$options
  • optional, an array of options

<

p>Options are :

  • 'excludeOrphans' - boolean value: true to exclude the orphans or false to include orphans in the result.
    Defaults to false
  • Returns

    array

    Throws

    ClientException@since
    2.2
    public triagens\ArangoDb\Graph
    # addEdgeDefinition( mixed $graph, triagens\ArangoDb\EdgeDefinition $edgeDefinition )

    adds an edge definition to the graph.

    adds an edge definition to the graph.

    This will add a further edge definition to the graph.

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $edgeDefinition
    • the new edge definition.

    Returns

    triagens\ArangoDb\Graph

    Throws

    triagens\ArangoDb\Exception

    Since

    2.2
    public triagens\ArangoDb\Graph
    # deleteEdgeDefinition( mixed $graph, string $edgeDefinition, boolean $dropCollection = false )

    deletes an edge definition from the graph.

    deletes an edge definition from the graph.

    This will delete an edge definition from the graph.

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $edgeDefinition
    • the name of the edge definitions relation.
    $dropCollection
    • if set to true the edge definitions collections are deleted.

    Returns

    triagens\ArangoDb\Graph

    Throws

    triagens\ArangoDb\Exception

    Since

    2.2
    public array
    # getEdgeCollections( mixed $graph )

    gets all edge collections from the graph.

    gets all edge collections from the graph.

    This will get all edge collections from the graph.

    If this method or any method that calls this method is used in batch mode and caching is off,
    then for each call, this method will make an out of batch API call to the db in order to get the appropriate collections.

    If caching is on, then the GraphHandler will only call the DB API once for the chosen graph, and return data from cache for the following calls.

    Parameters

    $graph
    • graph name as a string or instance of Graph

    Returns

    array

    Throws

    triagens\ArangoDb\Exception

    Since

    2.2
    public triagens\ArangoDb\Graph
    # replaceEdgeDefinition( mixed $graph, triagens\ArangoDb\EdgeDefinition $edgeDefinition )

    replaces an edge definition of the graph.

    replaces an edge definition of the graph.

    This will replace an edge definition in the graph.

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $edgeDefinition
    • the edge definition.

    Returns

    triagens\ArangoDb\Graph

    Throws

    triagens\ArangoDb\Exception

    Since

    2.2
    public string
    # saveVertex( mixed $graph, mixed $document, string $collection = null )

    save a vertex to a graph

    save a vertex to a graph

    This will add the vertex-document to the graph and return the vertex id

    This will throw if the vertex cannot be saved

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $document
    • the vertex to be added, can be passed as a vertex object or an array
    $collection
    • if one uses a graph with more than one vertex collection one must provide the collection to store the vertex.

    Returns

    string
    • id of vertex created

    Throws

    triagens\ArangoDb\Exception

    Since

    1.2
    public triagens\ArangoDb\Document
    # getVertex( mixed $graph, mixed $vertexId, array $options = [], string $collection = null )

    Get a single vertex from a graph

    Get a single vertex from a graph

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

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $vertexId
    • the vertex identifier
    $options

    optional, an array of options:

  • _includeInternals - true to include the internal attributes. Defaults to false
  • _ignoreHiddenAttributes - true to show hidden attributes. Defaults to false
  • $collection
    • if one uses a graph with more than one vertex collection one must provide the collection to load the vertex.

    Returns

    triagens\ArangoDb\Document

    Throws

    triagens\ArangoDb\Exception

    Since

    1.2
    public boolean
    # hasVertex( mixed $graph, mixed $vertexId )

    Check if a vertex exists

    Check if a vertex exists

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

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $vertexId
    • the vertex identifier

    Returns

    boolean

    Throws

    triagens\ArangoDb\Exception
    When any other error than a 404 occurs
    public boolean
    # replaceVertex( mixed $graph, mixed $vertexId, triagens\ArangoDb\Document $document, array $options = [], string $collection = null )

    Replace an existing vertex in a graph, identified graph name and vertex id

    Replace an existing vertex in a graph, identified graph name and vertex id

    This will update the vertex on the server

    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 vertex is the same as the one given.

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $vertexId
    • the vertex id as string or number
    $document
    • the vertex-document to be updated
    $options

    optional, an array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method):

  • revision - revision for conditional updates ('some-revision-id' [use the passed in revision id], false or true [use document's revision])
  • 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
  • $collection
    • if one uses a graph with more than one vertex collection one must provide the collection

    Returns

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

    Throws

    triagens\ArangoDb\Exception

    Since

    1.2
    public boolean
    # updateVertex( mixed $graph, mixed $vertexId, triagens\ArangoDb\Document $document, array $options = [], string $collection = null )

    Update an existing vertex in a graph, identified by graph name and vertex id

    Update an existing vertex in a graph, identified by graph name and vertex id

    This will update the vertex on the server

    This will throw if the vertex cannot be updated

    If policy is set to error (locally or globally through the ConnectionOptions) and the passed vertex-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

    $graph
    • graph name as a string or instance of Graph
    $vertexId
    • the vertex id as string or number
    $document
    • the patch vertex-document which contains the attributes and values to be updated
    $options

    optional, an array of options (see below)

  • 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
  • $collection
    • if one uses a graph with more than one vertex collection one must provide the collection

    Returns

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

    Throws

    triagens\ArangoDb\Exception

    Since

    1.2
    public boolean
    # removeVertex( mixed $graph, mixed $vertexId, mixed $revision = null, array $options = [], string $collection = null )

    Remove a vertex from a graph, identified by the graph name and vertex id

    Remove a vertex from a graph, identified by the graph name and vertex id

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $vertexId
    • the vertex id as string or number
    $revision
    • optional, the revision of the vertex to be deleted
    $options

    optional, an array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)

  • 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
  • $collection
    • if one uses a graph with more than one vertex collection one must provide the collection

    Returns

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

    Throws

    triagens\ArangoDb\Exception

    Since

    1.2
    public mixed
    # saveEdge( mixed $graph, mixed $from, mixed $to, mixed $label, mixed $document, string $collection = null )

    save an edge to a graph

    save an edge to a graph

    This will save the edge to the graph and return the edges-document's id

    This will throw if the edge cannot be saved

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $from
    • the 'from' vertex
    $to
    • the 'to' vertex
    $label
    • (optional) a label for the edge
    $document
    • the edge-document to be added, can be passed as an edge object or an array
    $collection
    • if one uses a graph with more than one vertex collection one must provide the collection

    Returns

    mixed
    • id of edge created

    Throws

    triagens\ArangoDb\Exception

    Since

    1.2
    public triagens\ArangoDb\Document
    # getEdge( mixed $graph, mixed $edgeId, array $options = [], string $collection = null )

    Get a single edge from a graph

    Get a single edge from a graph

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

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $edgeId
    • edge identifier
    $options

    optional, array of options

  • _includeInternals - true to include the internal attributes. Defaults to false
  • _ignoreHiddenAttributes - true to show hidden attributes. Defaults to false
  • $collection
    • if one uses a graph with more than one vertex collection one must provide the collection

    Returns

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

    Throws

    triagens\ArangoDb\Exception

    Since

    1.2
    public boolean
    # hasEdge( mixed $graph, mixed $edgeId )

    Check if an edge exists

    Check if an edge exists

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

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $edgeId
    • the vertex identifier

    Returns

    boolean

    Throws

    triagens\ArangoDb\Exception
    When any other error than a 404 occurs
    public boolean
    # replaceEdge( mixed $graph, mixed $edgeId, mixed $label, triagens\ArangoDb\Edge $document, array $options = [], string $collection = null )

    Replace an existing edge in a graph, identified graph name and edge id

    Replace an existing edge in a graph, identified graph name and edge id

    This will replace the edge on the server

    This will throw if the edge 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 edge is the same as the one given.

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $edgeId
    • edge id as string or number
    $label
    • label for the edge or ''
    $document
    • edge document to be updated
    $options

    optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)

  • 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
  • $collection
    • if one uses a graph with more than one vertex collection one must provide the collection

    Returns

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

    Throws

    triagens\ArangoDb\Exception

    Since

    1.2
    public boolean
    # updateEdge( mixed $graph, mixed $edgeId, mixed $label, triagens\ArangoDb\Edge $document, array $options = [], string $collection = null )

    Update an existing edge in a graph, identified by graph name and edge id

    Update an existing edge in a graph, identified by graph name and edge id

    This will update the edge on the server

    This will throw if the edge cannot be updated

    If policy is set to error (locally or globally through the ConnectionOptions) and the passed edge-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

    $graph
    • graph name as a string or instance of Graph
    $edgeId
    • edge id as string or number
    $label
    • label for the edge or ''
    $document
    • patch edge-document which contains the attributes and values to be updated
    $options

    optional, array of options (see below)

  • 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
  • $collection
    • if one uses a graph with more than one vertex collection one must provide the collection

    Returns

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

    Throws

    triagens\ArangoDb\Exception

    Since

    1.2
    public boolean
    # removeEdge( mixed $graph, mixed $edgeId, mixed $revision = null, array $options = [], string $collection = null )

    Remove a edge from a graph, identified by the graph name and edge id

    Remove a edge from a graph, identified by the graph name and edge id

    Parameters

    $graph
    • graph name as a string or instance of Graph
    $edgeId
    • edge id as string or number
    $revision
    • optional revision of the edge to be deleted
    $options

    optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)

  • 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
  • $collection
    • if one uses a graph with more than one vertex collection one must provide the collection

    Returns

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

    Throws

    triagens\ArangoDb\Exception

    Since

    1.2
    public
    # clearCache( )

    Clears the GraphHandler's cache

    Clears the GraphHandler's cache

    Returns


    $this
    public boolean
    # getCacheEnabled( )

    Checks if caching in enabled

    Checks if caching in enabled

    Returns

    boolean
    public
    # setCacheEnabled( boolean $useCache )

    Parameters

    $useCache

    Returns


    $this

    Methods inherited from triagens\ArangoDb\Handler

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

    Constants summary

    string ENTRY_GRAPH

    documents array index

    documents array index

    # 'graph'
    string OPTION_REVISION

    conditional update of edges or vertices

    conditional update of edges or vertices

    # 'revision'
    string OPTION_VERTICES

    vertex parameter

    vertex parameter

    # 'vertices'
    string OPTION_EDGES

    direction parameter

    direction parameter

    # 'edges'
    string OPTION_KEY

    direction parameter

    direction parameter

    # '_key'
    string OPTION_COLLECTION

    collection parameter

    collection parameter

    # 'collection'
    string OPTION_COLLECTIONS

    collections parameter

    collections parameter

    # 'collections'
    string KEY_FROM

    example parameter

    example parameter

    # '_from'
    string KEY_TO

    example parameter

    example parameter

    # '_to'
    string OPTION_NAME

    name parameter

    name parameter

    # 'name'
    string OPTION_EDGE_DEFINITION

    edge definition parameter

    edge definition parameter

    # 'edgeDefinition'
    string OPTION_EDGE_DEFINITIONS

    edge definitions parameter

    edge definitions parameter

    # 'edgeDefinitions'
    string OPTION_ORPHAN_COLLECTIONS

    orphan collection parameter

    orphan collection parameter

    # 'orphanCollections'
    string OPTION_DROP_COLLECTION

    drop collection

    drop collection

    # 'dropCollection'

    Properties summary

    protected $cache

    GraphHandler cache store

    GraphHandler cache store

    #
    protected boolean $cacheEnabled

    boolean GraphHandler use cache store

    boolean GraphHandler use cache store

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