Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.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
MongoDB组按键PHP_Php_Mongodb_Mongodb Php - Fatal编程技术网

MongoDB组按键PHP

MongoDB组按键PHP,php,mongodb,mongodb-php,Php,Mongodb,Mongodb Php,好的,我的MongoDB中有一个收藏 这是一个样本我的钥匙在这里 公司 现在的问题是我有4行/收集hoyts,我需要将它们分组 我当前的代码 public function getstore($storename) { // select a collection (analogous to a relational database's table) $collection = $this->db->products; /

好的,我的MongoDB中有一个收藏

这是一个样本我的钥匙在这里

公司

现在的问题是我有4行/收集hoyts,我需要将它们分组

我当前的代码

public function getstore($storename)
    {
        // select a collection (analogous to a relational database's table)
         $collection = $this->db->products;

        // find everything in the collection
        $cursor = $collection->find(array("store_name"=>$storename));

        $test = array();
            // iterate through the results
            while( $cursor->hasNext() ) {
                $test[] = ($cursor->getNext());
            }
        //Print Results 
        print json_encode($test);

    }
我试着用

组($key)->查找

然而,这并没有起作用

有人能帮我一下吗谢谢看这个例子:

public function getstore($storename)
    {
        // select a collection (analogous to a relational database's table)
         $collection = $this->db->products;

        // find everything in the collection
        $cursor = $collection->find(array("store_name"=>$storename));

        $test = array();
            // iterate through the results
            while( $cursor->hasNext() ) {
                $test[] = ($cursor->getNext());
            }
        //Print Results 
        print json_encode($test);

    }