\triagens\ArangoDbCollectionHandler

Provides management of collections

The collection handler fetches collection data from the server and creates collections on the server.

Summary

Methods
Properties
Constants
__construct()
get()
getProperties()
getCount()
count()
getFigures()
figures()
add()
create()
getChecksum()
getRevision()
createCapConstraint()
createGeoIndex()
createHashIndex()
createFulltextIndex()
createSkipListIndex()
index()
getIndex()
getIndexes()
dropIndex()
delete()
drop()
rename()
load()
unload()
truncate()
byExample()
fulltext()
firstExample()
any()
first()
last()
updateByExample()
replaceByExample()
removeByExample()
range()
all()
near()
within()
getAllIds()
isValidCollectionId()
getAllCollections()
getCollectionId()
getCollectionName()
importFromFile()
import()
No public properties found
ENTRY_DOCUMENTS
OPTION_COLLECTION
OPTION_EXAMPLE
OPTION_NEW_VALUE
OPTION_CREATE_COLLECTION
OPTION_ATTRIBUTE
OPTION_LEFT
OPTION_RIGHT
OPTION_CLOSED
OPTION_LATITUDE
OPTION_LONGITUDE
OPTION_DISTANCE
OPTION_RADIUS
OPTION_SKIP
OPTION_INDEX
OPTION_LIMIT
OPTION_FIELDS
OPTION_UNIQUE
OPTION_TYPE
OPTION_CAP_CONSTRAINT
OPTION_SIZE
OPTION_GEO_INDEX
OPTION_IGNORE_NULL
OPTION_CONSTRAINT
OPTION_GEOJSON
OPTION_HASH_INDEX
OPTION_FULLTEXT_INDEX
OPTION_MIN_LENGTH
OPTION_SKIPLIST_INDEX
OPTION_COUNT
OPTION_QUERY
OPTION_CHECKSUM
OPTION_REVISION
OPTION_PROPERTIES
OPTION_FIGURES
OPTION_LOAD
OPTION_UNLOAD
OPTION_TRUNCATE
OPTION_RENAME
OPTION_EXCLUDE_SYSTEM
getConnection()
getConnectionOption()
getCursorOptions()
json_encode_wrapper()
validateAndIncludeOldSingleParameterInParams()
includeOptionsInParams()
includeOptionsInBody()
No protected properties found
N/A
No private methods found
$_connection
N/A

Constants

ENTRY_DOCUMENTS

ENTRY_DOCUMENTS

documents array index

OPTION_COLLECTION

OPTION_COLLECTION

collection parameter

OPTION_EXAMPLE

OPTION_EXAMPLE

example parameter

OPTION_NEW_VALUE

OPTION_NEW_VALUE

example parameter

OPTION_CREATE_COLLECTION

OPTION_CREATE_COLLECTION

example parameter

OPTION_ATTRIBUTE

OPTION_ATTRIBUTE

attribute parameter

OPTION_LEFT

OPTION_LEFT

left parameter

OPTION_RIGHT

OPTION_RIGHT

right parameter

OPTION_CLOSED

OPTION_CLOSED

closed parameter

OPTION_LATITUDE

OPTION_LATITUDE

latitude parameter

OPTION_LONGITUDE

OPTION_LONGITUDE

longitude parameter

OPTION_DISTANCE

OPTION_DISTANCE

distance parameter

OPTION_RADIUS

OPTION_RADIUS

radius parameter

OPTION_SKIP

OPTION_SKIP

skip parameter

OPTION_INDEX

OPTION_INDEX

index parameter

OPTION_LIMIT

OPTION_LIMIT

limit parameter

OPTION_FIELDS

OPTION_FIELDS

count fields

OPTION_UNIQUE

OPTION_UNIQUE

count unique

OPTION_TYPE

OPTION_TYPE

count unique

OPTION_CAP_CONSTRAINT

OPTION_CAP_CONSTRAINT

cap constraint option

OPTION_SIZE

OPTION_SIZE

size option

OPTION_GEO_INDEX

OPTION_GEO_INDEX

geo index option

OPTION_IGNORE_NULL

OPTION_IGNORE_NULL

ignoreNull option

OPTION_CONSTRAINT

OPTION_CONSTRAINT

constraint option

OPTION_GEOJSON

OPTION_GEOJSON

geoJson option

OPTION_HASH_INDEX

OPTION_HASH_INDEX

hash index option

OPTION_FULLTEXT_INDEX

OPTION_FULLTEXT_INDEX

fulltext index option

OPTION_MIN_LENGTH

OPTION_MIN_LENGTH

minLength option

OPTION_SKIPLIST_INDEX

OPTION_SKIPLIST_INDEX

skiplist index option

OPTION_COUNT

OPTION_COUNT

count option

OPTION_QUERY

OPTION_QUERY

query option

OPTION_CHECKSUM

OPTION_CHECKSUM

checksum option

OPTION_REVISION

OPTION_REVISION

revision option

OPTION_PROPERTIES

OPTION_PROPERTIES

properties option

OPTION_FIGURES

OPTION_FIGURES

figures option

OPTION_LOAD

OPTION_LOAD

load option

OPTION_UNLOAD

OPTION_UNLOAD

unload option

OPTION_TRUNCATE

OPTION_TRUNCATE

truncate option

OPTION_RENAME

OPTION_RENAME

rename option

OPTION_EXCLUDE_SYSTEM

OPTION_EXCLUDE_SYSTEM

exclude system collections

Properties

$_connection

$_connection : 

Connection object

Type

Methods

get()

get(mixed $collectionId) : \triagens\ArangoDb\Collection

Get information about a collection

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

Parameters

mixed $collectionId
  • collection id as a string or number

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\Collection
  • the collection fetched from the server

getProperties()

getProperties(mixed $collectionId) : \triagens\ArangoDb\Collection

Get properties of a collection

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

Parameters

mixed $collectionId
  • collection id as a string or number

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\Collection
  • the collection fetched from the server

getCount()

getCount(mixed $collectionId) : integer

Get the number of documents in a collection

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

Parameters

mixed $collectionId
  • collection id as a string or number

Throws

\triagens\ArangoDb\Exception

Returns

integer —
  • the number of documents in the collection

count()

count(mixed $collectionId) : integer

Get the number of documents in a collection

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

Parameters

mixed $collectionId
  • collection id as a string or number

Throws

\triagens\ArangoDb\Exception

Returns

integer —
  • the number of documents in the collection

getFigures()

getFigures(mixed $collectionId) : array

Get figures for a collection

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

Parameters

mixed $collectionId
  • collection id as a string or number

Throws

\triagens\ArangoDb\Exception

Returns

array —
  • the figures for the collection

figures()

figures(mixed $collectionId) : array

Get figures for a collection

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

Parameters

mixed $collectionId
  • collection id as a string or number

Throws

\triagens\ArangoDb\Exception

Returns

array —
  • the figures for the collection

add()

add(\triagens\ArangoDb\Collection $collection) : mixed

Adds a new collection on the server

This will add the collection on the server and return its id

This will throw if the collection cannot be created

Parameters

\triagens\ArangoDb\Collection $collection
  • collection object to be created on the server

Throws

\triagens\ArangoDb\Exception

Returns

mixed —
  • id of collection created

create()

create(mixed $collection, array $options) : mixed

Creates a new collection on the server

This will add the collection on the server and return its id The id is mainly returned for backwards compatibility, but you should use the collection name for any reference to the collection. * This will throw if the collection cannot be created

Parameters

mixed $collection
  • collection object to be created on the server or a string with the name
array $options
  • an array of options.
                     <p>Options are :<br>
                     <li>'type'            - 2 -> normal collection, 3 -> edge-collection</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>
                     <li>'journalSize'     -  journalSize value.</li>
                     <li>'isSystem'        -  false->user collection(default), true->system collection .</li>
                     <li>'isVolatile'      -  false->persistent collection(default), true->volatile (in-memory) collection .</li>
                     <li>'numberOfShards'  -  number of shards for the collection.</li>
                     <li>'shardKeys'       -  list of shard key attributes.</li>
                     </p>

Throws

\triagens\ArangoDb\Exception

Returns

mixed —
  • id of collection created

getChecksum()

getChecksum(mixed $collectionId, boolean $withRevisions, boolean $withData) : array

Calculate a checksum of the collection.

Will calculate a checksum of the meta-data (keys and optionally revision ids) and optionally the document data in the collection.

Parameters

mixed $collectionId
  • collection id as a string or number
boolean $withRevisions
  • optional boolean whether or not to include document revision ids
                            in the checksum calculation.
boolean $withData
  • optional boolean whether or not to include document body data in the
                                 checksum calculation.

Throws

\triagens\ArangoDb\Exception

Returns

array —
  • array containing keys "checksum" and "revision"

getRevision()

getRevision(mixed $collectionId) : array

Returns the Collections revision ID

The revision id is a server-generated string that clients can use to check whether data in a collection has changed since the last revision check.

Parameters

mixed $collectionId
  • collection id as a string or number

Throws

\triagens\ArangoDb\Exception

Returns

array —
  • containing a key revision

createCapConstraint()

createCapConstraint(string $collectionId, integer $size) : array

Create a cap constraint

Parameters

string $collectionId
  • the collection id
integer $size
  • the size of the cap constraint

Returns

array —
  • server response of the created index

createGeoIndex()

createGeoIndex(string $collectionId, array $fields, boolean $geoJson, boolean $constraint, boolean $ignoreNull) : array

Create a geo index

Parameters

string $collectionId
  • the collection id
array $fields
  • an array of fields
boolean $geoJson
  • whether to use geoJson or not
boolean $constraint
  • whether this is a constraint or not
boolean $ignoreNull
  • whether to ignore null

Returns

array —
  • server response of the created index

createHashIndex()

createHashIndex(string $collectionId, array $fields, boolean $unique) : array

Create a hash index

Parameters

string $collectionId
  • the collection id
array $fields
  • an array of fields
boolean $unique
  • whether the values in the index should be unique or not

Returns

array —
  • server response of the created index

createFulltextIndex()

createFulltextIndex(string $collectionId, array $fields, integer $minLength) : array

Create a fulltext index

Parameters

string $collectionId
  • the collection id
array $fields
  • an array of fields
integer $minLength
  • the minimum length of words to index

Returns

array —
  • server response of the created index

createSkipListIndex()

createSkipListIndex(string $collectionId, array $fields, boolean $unique) : array

Create a skip-list index

Parameters

string $collectionId
  • the collection id
array $fields
  • an array of fields
boolean $unique
  • whether the index is unique or not

Returns

array —
  • server response of the created index

index()

index(mixed $collectionId, string $type, array $attributes, boolean $unique, array $indexOptions) : array

Creates an index on a collection on the server

This will create an index on the collection on the server and return its id

This will throw if the index cannot be created

Parameters

mixed $collectionId
  • The id of the collection where the index is to be created
string $type
  • index type: hash, skiplist or geo
array $attributes
  • an array of attributes that can be defined like array('a') or array('a', 'b.c')
boolean $unique
  • true/false to create a unique index
array $indexOptions
  • an associative array of options for the index like array('geoJson' => true)

Throws

\triagens\ArangoDb\Exception

Returns

array —
  • server response of the created index

getIndex()

getIndex(string $collection, string $indexId) : array

Get the information about an index in a collection

Parameters

string $collection
  • the id of the collection
string $indexId
  • the id of the index

Returns

array

getIndexes()

getIndexes(mixed $collectionId) : array

Get indexes of a collection

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

Parameters

mixed $collectionId
  • collection id as a string or number

Throws

\triagens\ArangoDb\Exception

Returns

array —

$data - the indexes result-set from the server

dropIndex()

dropIndex(mixed $indexHandle) : boolean

Drop an index

Parameters

mixed $indexHandle
  • index handle (collection name / index id)

Throws

\triagens\ArangoDb\Exception

Returns

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

delete()

delete(mixed $collection) : boolean

Delete a collection

Parameters

mixed $collection
  • collection id as string or number or collection object

Throws

\triagens\ArangoDb\Exception

Returns

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

drop()

drop(mixed $collection) : boolean

Drop a collection

Parameters

mixed $collection
  • collection id as string or number or collection object

Throws

\triagens\ArangoDb\Exception

Returns

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

rename()

rename(mixed $collection, string $name) : boolean

Rename a collection

Parameters

mixed $collection
  • collection id as string or number or collection object
string $name
  • new name for collection

Throws

\triagens\ArangoDb\Exception

Returns

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

load()

load(mixed $collection) : \triagens\ArangoDb\HttpResponse

Load a collection into the server's memory

This will load the given collection into the server's memory.

Parameters

mixed $collection
  • collection id as string or number or collection object

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\HttpResponse
  • HTTP response object

unload()

unload(mixed $collection) : \triagens\ArangoDb\HttpResponse

Unload a collection from the server's memory

This will unload the given collection from the server's memory.

Parameters

mixed $collection
  • collection id as string or number or collection object

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\HttpResponse
  • HTTP response object

truncate()

truncate(mixed $collection) : boolean

Truncate a collection

This will remove all documents from the collection but will leave the metadata and indexes intact.

Parameters

mixed $collection
  • collection id as string or number or collection object

Throws

\triagens\ArangoDb\Exception

Returns

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

byExample()

byExample(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

fulltext()

fulltext(mixed $collectionId, mixed $attribute, mixed $query, boolean|array $options) : \triagens\ArangoDb\cursor

Get document(s) by a fulltext query

This will find all documents from the collection that match the fulltext query specified in query. In order to use the fulltext operator, a fulltext index must be defined for the collection and the specified attribute.

Parameters

mixed $collectionId
  • collection id as string or number
mixed $attribute
  • The attribute that contains the texts.
mixed $query
  • The fulltext query.
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>
                            <li>'index'     - If given, the identifier of the fulltext-index to use.</li>
                            </p>

Throws

\triagens\ArangoDb\Exception

Returns

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

firstExample()

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

Get the first document matching a given example.

This will throw if the document 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, 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>
                            </p>

Throws

\triagens\ArangoDb\Exception

Returns

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

any()

any(mixed $collectionId) : \triagens\ArangoDb\Document

Get a random document from the collection.

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

Parameters

mixed $collectionId
  • collection id as string or number

Throws

\triagens\ArangoDb\Exception

Returns

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

first()

first(mixed $collectionId, integer $count) : array

This will return the first documents from the collection, in the order of insertion/update time.

When the count argument is supplied, the result will be a list of documents, with the "oldest" document being first in the result list. If the count argument is not supplied, the result is the "oldest" document of the collection, or null if the collection is empty.

Parameters

mixed $collectionId
  • collection id as string or number
integer $count
  • the number of documents to return at most. Specifiying count is optional.

Throws

\triagens\ArangoDb\Exception

Returns

array —
  • array of documents in the collection

last()

last(mixed $collectionId, integer $count) : array

This will return the last documents from the collection, in the order of insertion/update time.

When the count argument is supplied, the result will be a list of documents, with the "latest" document being first in the result list. If the count argument is not supplied, the result is the "latest" document of the collection, or null if the collection is empty.

Parameters

mixed $collectionId
  • collection id as string or number
integer $count
  • the number of documents to return at most. Specifiying count is optional.

Throws

\triagens\ArangoDb\Exception

Returns

array —
  • array of documents in the collection

updateByExample()

updateByExample(mixed $collectionId, mixed $example, mixed $newValue, mixed $options) : boolean

Update document(s) matching a given example

This will update the document(s) on the server

This will throw if the document cannot be updated

Parameters

mixed $collectionId
  • collection id as string or number
mixed $example
  • the example document as a Document object or an array
mixed $newValue
  • patch document or array 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>'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>
                       <li>'limit'       - can be used set a limit on how many documents to update at most. If limit is specified but is less than the number of documents in the collection, it is undefined which of the documents will be updated.</li>
                       </p>

Throws

\triagens\ArangoDb\Exception

Returns

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

replaceByExample()

replaceByExample(mixed $collectionId, mixed $example, mixed $newValue, mixed $options) : boolean

Replace document(s) matching a given example

This will replace the document(s) on the server

This will throw if the document cannot be replaced

Parameters

mixed $collectionId
  • collection id as string or number
mixed $example
  • the example document as a Document object or an array
mixed $newValue
  • patch document or array which contains the attributes and values to be replaced
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>'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 replace operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
                       <li>'limit'       - can be used set a limit on how many documents to replace at most. If limit is specified but is less than the number of documents in the collection, it is undefined which of the documents will be replaced.</li>
                       </p>

Throws

\triagens\ArangoDb\Exception

Returns

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

removeByExample()

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

Remove document(s) by specifying an example

This will throw on any error

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 - an array of options.
                            <p>Options are :<br>
                            <li>
                            'waitForSync' -  if set to true, then all removal operations will instantly be synchronised to disk.<br>
                            If this is not specified, then the collection's default sync behavior will be applied.
                            </li>
                            </p>
                            <li>'limit' -  Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.</li>

Throws

\triagens\ArangoDb\Exception

Returns

integer —
  • number of documents that were deleted

range()

range(mixed $collectionId, string $attribute, mixed $left, mixed $right, array $options) : \triagens\ArangoDb\Cursor

Get document(s) by specifying range

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

Parameters

mixed $collectionId
  • collection id as string or number
string $attribute
  • the attribute path , like 'a', 'a.b', etc...
mixed $left
  • The lower bound.
mixed $right
  • The upper bound.
array $options
  • optional 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>
  • 'closed' - If true, use interval including left and right, otherwise exclude right, but include left.
  • 'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch
  • 'skip' - Optional, The number of documents to skip in the query.
  • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\Cursor
  • documents matching the example [0...n]

all()

all(mixed $collectionId, array $options) : \triagens\ArangoDb\Cursor

Returns all documents of a collection

Parameters

mixed $collectionId
  • collection id as string or number
array $options
  • optional 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>
  • 'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch
  • 'skip' - Optional, The number of documents to skip in the query.
  • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.

Returns

\triagens\ArangoDb\Cursor
  • documents

near()

near(mixed $collectionId, double $latitude, double $longitude, array $options) : \triagens\ArangoDb\Cursor

Get document(s) by specifying near

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

Parameters

mixed $collectionId
  • collection id as string or number
double $latitude
  • The latitude of the coordinate.
double $longitude
  • The longitude of the coordinate.
array $options
  • optional 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>
  • 'distance' - If given, the attribute key used to store the distance. (optional)
  • 'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch
  • 'skip' - Optional, The number of documents to skip in the query.
  • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\Cursor
  • documents matching the example [0...n]

within()

within(mixed $collectionId, double $latitude, double $longitude, integer $radius, array $options) : \triagens\ArangoDb\Cursor

Get document(s) by specifying within

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

Parameters

mixed $collectionId
  • collection id as string or number
double $latitude
  • The latitude of the coordinate.
double $longitude
  • The longitude of the coordinate.
integer $radius
  • The maximal radius (in meters).
array $options
  • optional 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>
  • 'distance' - If given, the attribute key used to store the distance. (optional)
  • 'batchSize' - can optionally be used to tell the server to limit the number of results to be transferred in one batch
  • 'skip' - Optional, The number of documents to skip in the query.
  • 'limit' - Optional, The maximal amount of documents to return. 'skip' is applied before the limit restriction.

Throws

\triagens\ArangoDb\Exception

Returns

\triagens\ArangoDb\Cursor
  • documents matching the example [0...n]

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

isValidCollectionId()

isValidCollectionId( $collectionId) : boolean

Checks if the collectionId given, is valid. Returns true if it is, or false if it is not.

Parameters

$collectionId

Returns

boolean

getAllCollections()

getAllCollections(array $options) : array

Get list of all available collections per default with the collection names as index.

Returns empty array if none are available.

Parameters

array $options
  • optional - an array of options.
                             <p>Options are :<br>
                             <li>'excludeSystem' -   With a value of true, all system collections will be excluded from the response.</li>
                             <li>'keys' -  With a value of "collections", the index of the resulting array is numerical,
                             With a value of "names", the index of the resulting array are the collection names.</li>
                             </p>

Returns

array

getCollectionId()

getCollectionId(mixed $collection) : mixed

Gets the collectionId from the given collectionObject or string/integer

Parameters

mixed $collection

Returns

mixed

getCollectionName()

getCollectionName(mixed $collection) : mixed

Gets the collectionId from the given collectionObject or string/integer

Parameters

mixed $collection

Returns

mixed

importFromFile()

importFromFile(mixed $collectionId, mixed $importFileName, array $options) : integer

Import documents from a file

This will throw on all errors except insertion errors

Parameters

mixed $collectionId
  • collection id as string or number
mixed $importFileName
  • The filename that holds the import data.
array $options
  • optional - an array of options.
                         <p>Options are :<br>
                         'type' -  if type is not set or it's set to '' or null, the Header-Value format must be provided in the import file.<br>
                         <p>
                         <li>                       if set to 'documents', then the file's content must have its documents line by line. Each line will be interpreted as a document.</li>
                         <li>                       if set to 'array' then the file's content must provide the documents as a list of documents instead of the above line by line.</li>
                         <br>
                         More info on how the import functionality works: <a href ="https://github.com/triAGENS/ArangoDB/wiki/HttpImport">https://github.com/triAGENS/ArangoDB/wiki/HttpImport</a>
                         </p>
                         <br>
                         </li>
                         <li>'createCollection' - If true, create the collection if it doesn't exist. Defaults to false </li>
                         </p>

Throws

\triagens\ArangoDb\Exception

Returns

integer —
  • number of documents that were deleted

import()

import(mixed $collectionId, mixed $importData, array $options) : integer

Import documents into a collection

This will throw on all errors except insertion errors

Parameters

mixed $collectionId
  • collection id as string or number
mixed $importData
  • The data to import. This can be a string holding the data according to the type of import, or an array of documents
array $options
  • optional - an array of options.
                       <p>Options are :<br>
                       <li>
                       'type' -  if type is not set or it's set to '' or null, the Header-Value format must be provided in the import file.<br>
                       <p>
                       <li>                       if set to 'documents', then the file's content must have its documents line by line. Each line will be interpreted as a document.</li>
                       <li>                       if set to 'array' then the file's content must provide the documents as a list of documents instead of the above line by line.</li>
                       <br>
                       More info on how the import functionality works: <a href ="https://github.com/triAGENS/ArangoDB/wiki/HttpImport">https://github.com/triAGENS/ArangoDB/wiki/HttpImport</a>
                       </p>
                       <br>

  • 'createCollection' - If true, create the collection if it doesn't exist. Defaults to false

Throws

\triagens\ArangoDb\Exception

Returns

integer —
  • number of documents that were deleted

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