php - 区别使用 Mongo db 和 php
问题描述
function Function_Name()
{
$command = new MongoDB\Driver\Command
([
'distinct' => 'Collection name', // Enter Collection/table name
'key' => 'Field Name' // which field you want to distinct.
'query' => $query // You can use your filter condition here.
]);
$cursor = $GLOBALS['ConManager']->executeCommand($this->dbname, $command);
// to get distinct values as array
$instances = current($cursor->toArray())->values;//retriving current value of the array element.
return $instances;
}
在此示例中,我们使用执行 mongo 驱动程序命令从集合中检索不同的数据。
解决方案
推荐阅读
- javascript - 使用 JS FileReader API 读取 Sharepoint 文档库文件
- google-chrome - 加载未打包的 Chrome 扩展程序 - 它如何知道我的 index.html 文件在哪里?
- python-3.x - 在 Python 3.7 中导入序列
- api - 如何递归列出onedrive api中的文件夹?
- sql - 在 CASE 语句中使用 JSON_MODIFY 和 JSON_QUERY 的问题
- go - 使用 Go SDK,如何将 DynamoDB 表项字段设置为地图?
- c# - C# 中的 PriorityQueue 初始化未正确排序
- python-sphinx - Python-Sphinx:自动包含文档构建的日期和时间
- python - 球拍:像python的numpy一样的O(1)数组索引?
- sql - 连接 3 个不同的字符串,然后将结果字符串存储在一列中