Unclear how can I run a simple query with transaction in PHP ?
I have tried this way :
$connection = new Connection($connectionOptions);
$query = 'FOR u IN Courses
FILTER u.Available positions > 0
FILTER u._key == "1672779"
UPDATE u WITH { Available positions: u.Available positions-1 } IN Courses
RETURN NEW';
$writeCollections = ["Courses"];
$action = "function () {
$cursor = $statement->execute()
}";
$waitForSync = true;
$lockTimeout = 10;
// check if setters work fine
$transaction = new Transaction($connection);
$transaction->writeCollections = "Courses";
$transaction->action = $action;
$transaction->waitForSync = true;
$transaction->lockTimeout = 10;
$transaction->execute();
but i got this notice, and don`t works :
Notice: Undefined variable: cursor on line 28
Notice: Undefined property: ArangoDBClient\Statement::$execute on line 28
ArangoDBClient\ServerException: 10 missing/invalid action definition for transaction - Uncaught SyntaxError: Unexpected token = - SyntaxError: Unexpected token = at new Function ()
What is the solution to run this query with transaction?
Unclear how can I run a simple query with transaction in PHP ?
I have tried this way :
$connection = new Connection($connectionOptions);
$query = 'FOR u IN Courses FILTER u.
Available positions
> 0 FILTER u._key == "1672779" UPDATE u WITH {Available positions
: u.Available positions
-1 } IN Courses RETURN NEW';$statement = new Statement( $connection, array( "query" => $query, "count" => true, "batchSize" => 1000, "sanitize" => true ) );
$transaction->execute();
but i got this notice, and don`t works : Notice: Undefined variable: cursor on line 28 Notice: Undefined property: ArangoDBClient\Statement::$execute on line 28 ArangoDBClient\ServerException: 10 missing/invalid action definition for transaction - Uncaught SyntaxError: Unexpected token = - SyntaxError: Unexpected token = at new Function ()
What is the solution to run this query with transaction?