Как вернуть значение из транзакции arangodb в php?

Я пытаюсь вернуть созданный ключ следующей транзакцией:

$trans=new Transaction($connection,array( 'collections' => array( 'write' => array( 'users','group_relations','groups' ),'read'=> array( 'users','group_relations','groups' ) ), 'waitForSync' => true ));
$trans->setAction('function(){
var db= require("@arangodb").db;
var ids = [];
db.groups.insert([{"name":"'.$name.'","type":"'.$type.'","restriction":"'.$restriction.'","picture":"'.$picture.'"}]).forEach(
function(obj) {ids.push(obj._key);});
db.group_relations.insert({"_from":"users/'.$_SESSION['uid'].'","_to":"groups/"+ids["0"],"status":"admin"});
return ids["0"];
}');
echo $trans->execute();

Может кто-нибудь помочь с этим вопросом?

1

Решение

Из документации:

/**
147      * Execute the transaction
148      *
149      * This will post the query to the server and return the results as
150      * a Cursor. The cursor can then be used to iterate the results.
151      *
152      * @throws Exception throw exception if transaction failed
153      * @return mixed true if successful without a return value or the return value if one was set in the action
154      */

Просто назначьте значение.

0

Другие решения

Других решений пока нет …