亲爱的所有可以提供帮助的人,
Dear everybody who can help,
我有这个 PHP > MongoDB 问题,我想通过 PHP 调用存储过程(存储在 db.system.js 集合中).
I have this PHP > MongoDB problem, I want to call a stored procedure (stored in db.system.js collection) via PHP.
我没有参数,只有一个返回的 JSON 对象,如下所示:
I have no parameters, only a returning JSON object which looks like this:
{"archived":[the number of the archived messages]}它在数据库服务器的 shell 中运行良好,但是当我尝试通过 PHP 驱动程序调用它时,它只是不说"任何事情......
It works good in the shell on the database server, but when I try to call it via the PHP driver it just doesn't "say" anything...
我的代码如下所示:
$DB->execute( new MongoCode( "function () { return archiveMessages(); }" ) );我也尝试过这样使用:
$DB->execute("archiveMessages()");请帮忙,我被这个卡住了...我只想在更新集合后调用那个 sh*t...
Please help, I've got stuck on this one... I only want to call that sh*t after updating the collection...
先谢谢你,乙
推荐答案您确定要使用相同的数据库吗?尝试将其简化为一个基本示例,例如
Are you sure you're using the same database? Try simplifying it to a basic example, e.g.,
$m = new Mongo(); $db = $m->foo; $db->system->js->save(array("_id"=>"archiveMessages", "value"=>new MongoCode("function() { return 3; }"))); print_r($db->execute("archiveMessages()"));结果:
Array ( [retval] => 3 [ok] => 1 )更多推荐
在 MongoDB 中通过 PHP 调用存储过程
发布评论