Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用MongoDB::命令进行查询_Php_Mongodb - Fatal编程技术网

Php 使用MongoDB::命令进行查询

Php 使用MongoDB::命令进行查询,php,mongodb,Php,Mongodb,我正在读MongoDB::command,但他们觉得我很可怜。如何使用::命令查询集合 假设我有一组事物,每个事物都有一个路径(其他事物的ID的字母数字字符串与/连接)。如何查询所有以/2e3r4t/开头的内容 也许吧 ?MongoDB::命令用于将原始数据发送到服务器。对于最常见的命令,您将在语言库中找到一个包装器 这里,根据您的描述,您需要。诸如此类(未经测试——小心打字错误): 有趣的是,从MongoDB 3.0.2开始,find命令没有文档记录,显然还没有作为DB命令实现: > d

我正在读
MongoDB::command
,但他们觉得我很可怜。如何使用
::命令
查询集合

假设我有一组
事物
,每个事物都有一个
路径
(其他
事物
的ID的字母数字字符串与
/
连接)。如何查询所有以
/2e3r4t/
开头的
内容

也许吧


MongoDB::命令用于将原始数据发送到服务器。对于最常见的命令,您将在语言库中找到一个包装器

这里,根据您的描述,您需要。诸如此类(未经测试——小心打字错误):

有趣的是,从MongoDB 3.0.2开始,
find
命令没有文档记录,显然还没有作为DB命令实现:

> db.runCommand({find: "w"})
{ "ok" : 0, "errmsg" : "find command not yet implemented" }
因此,对于这一个,您将不得不依赖于您的驱动程序的相应方法


编辑:快速查找命令是在3.1.0和3.1.1之间执行的:


@alexandernst自3.0.2版起,此功能尚不受支持。
$m = new MongoClient();
$db = $m->selectDB('test');
$collection = new MongoCollection($db, 'thing');

$regex = new MongoRegex("/^\/2e3r4t\//");
$collection->find(array('path' => $regex));
> db.runCommand({find: "w"})
{ "ok" : 0, "errmsg" : "find command not yet implemented" }