首页 > 解决方案 > 区别使用 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 驱动程序命令从集合中检索不同的数据。

标签: phpmongodbfunctionzend-frameworkdistinct

解决方案


推荐阅读