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 Transaction

Transaction object

A transaction is an object that is used to prepare and send a transaction to the server.

The object encapsulates:

  • the collections definitions for locking
  • the actual javascript function
  • additional options like waitForSync, lockTimeout and params

The transaction object requires the connection object and can be initialized with or without initial transaction configuration. Any configuration can be set and retrieved by the object's methods like this:

$this->setAction('function (){your code};');
$this->setCollections(array('read' => 'my_read_collection, 'write' => array('col_1', 'col2')));


or like this:

$this->action('function (){your code};');
$this->collections(array('read' => 'my_read_collection, 'write' => array('col_1', 'col2')));


There are also helper functions to set collections directly, based on their locking:

$this->setWriteCollections($array or $string if single collection)
$this->setReadCollections($array or $string if single collection)


Namespace: triagens\ArangoDb
Package: triagens\ArangoDb
Since: 1.3
Located at Transaction.php

Methods summary

public
# __construct( triagens\ArangoDb\Connection $connection, array $transactionArray = null )

Initialise the transaction object

Initialise the transaction object

The $transaction array can be used to specify the collections, action and further options for the transaction in form of an array.

Example: array( 'collections' => array( 'write' => array( 'my_collection' ) ), 'action' => 'function (){}', 'waitForSync' => true )

Parameters

$connection
  • the connection to be used
$transactionArray
  • transaction initialization data

Throws

triagens\ArangoDb\ClientException
public mixed
# execute( )

Execute the transaction

Execute the transaction

This will post the query to the server and return the results as a Cursor. The cursor can then be used to iterate the results.

Returns

mixed
true if successful without a return value or the return value if one was set in the action

Throws

triagens\ArangoDb\Exception
throw exception if transaction failed
protected triagens\ArangoDb\Connection
# getConnection( )

Return the connection object

Return the connection object

Returns

triagens\ArangoDb\Connection
  • the connection object
public
# setCollections( array $value )

Set the collections array.

Set the collections array.

The array should have 2 sub-arrays, namely 'read' and 'write' which should hold the respective collections for the transaction

Parameters

$value
public array
# getCollections( )

Get collections array

Get collections array

This holds the read and write collections of the transaction

Returns

array
$value
public
# setAction( string $value )

set action value

set action value

Parameters

$value

Throws

triagens\ArangoDb\ClientException
public string
# getAction( )

get action value

get action value

Returns

string
action
public
# setWaitForSync( boolean $value )

set waitForSync value

set waitForSync value

Parameters

$value

Throws

triagens\ArangoDb\ClientException
public boolean
# getWaitForSync( )

get waitForSync value

get waitForSync value

Returns

boolean
waitForSync
public
# setLockTimeout( integer $value )

Set lockTimeout value

Set lockTimeout value

Parameters

$value

Throws

triagens\ArangoDb\ClientException
public integer
# getLockTimeout( )

Get lockTimeout value

Get lockTimeout value

Returns

integer
lockTimeout
public
# setParams( array $value )

Set params value

Set params value

Parameters

$value

Throws

triagens\ArangoDb\ClientException
public array
# getParams( )

Get params value

Get params value

Returns

array
params
public
# setWriteCollections( array $value )

Convenience function to directly set write-collections without having to access them from the collections attribute.

Convenience function to directly set write-collections without having to access them from the collections attribute.

Parameters

$value
public array
# getWriteCollections( )

Convenience function to directly get write-collections without having to access them from the collections attribute.

Convenience function to directly get write-collections without having to access them from the collections attribute.

Returns

array
params
public
# setReadCollections( array $value )

Convenience function to directly set read-collections without having to access them from the collections attribute.

Convenience function to directly set read-collections without having to access them from the collections attribute.

Parameters

$value
public array
# getReadCollections( )

Convenience function to directly get read-collections without having to access them from the collections attribute.

Convenience function to directly get read-collections without having to access them from the collections attribute.

Returns

array
params
public
# set( $key, $value )

Sets an attribute

Sets an attribute

Parameters

$key
$value

Throws

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

Set an attribute, magic method

Set an attribute, magic method

This is a magic method that allows the object to be used without declaring all document attributes first.

Parameters

$key
  • attribute name
$value
  • value for attribute

Throws

triagens\ArangoDb\ClientException

Magic

public mixed
# get( string $key )

Get an attribute

Get an attribute

Parameters

$key
  • name of attribute

Returns

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

Get an attribute, magic method

Get an 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 string
# __toString( )

Returns the action string

Returns the action string

Returns

string
  • the current action string

Magic

public
# buildTransactionAttributesFromArray( $options )

Build the object's attributes from a given array

Build the object's attributes from a given array

Parameters

$options

Throws

triagens\ArangoDb\ClientException

Constants summary

string ENTRY_COLLECTIONS

Collections index

Collections index

# 'collections'
string ENTRY_ACTION

Action index

Action index

# 'action'
string ENTRY_WAIT_FOR_SYNC

WaitForSync index

WaitForSync index

# 'waitForSync'
string ENTRY_LOCK_TIMEOUT

Lock timeout index

Lock timeout index

# 'lockTimeout'
string ENTRY_PARAMS

Params index

Params index

# 'params'
string ENTRY_READ

Read index

Read index

# 'read'
string ENTRY_WRITE

WRITE index

WRITE index

# 'write'

Properties summary

protected array $attributes

The transaction's attributes.

The transaction's attributes.

# []
protected $_action

string The action property of the transaction.

string The action property of the transaction.

#

Magic properties

public array $collection
  • The collections array that includes both read and write collection definitions
public mixed $readCollection
  • The read-collections array or string (if only one)
public mixed $writeCollection
  • The write-collections array or string (if only one)
public string $action
  • The action to pass to the server
public boolean $waitForSync
  • WaitForSync on the transaction
public integer $lockTimeout
  • LockTimeout on the transaction
ArangoDB-PHP API Documentation API documentation generated by ApiGen