繁体   English   中英

如何从php中的arangodb事务返回值?

[英]How to return value from an arangodb transaction in 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();

有人可以帮忙吗?

从文档中:

/**
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      */

只需分配值即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM