好的,所以我在我的MongoDB中有一个集合
这是一个示例,我的密钥在这里是
公司
{
"_id": ObjectId("4fdfe7b536314b4147000000"),
"company": "hoyts",
"barcode": "236602253",
"name": "Gold Class",
"logoURL": "http: '/'/www.incard.com.au'/newsite'/template'/images'/movieticket'/4cinemas'/ticketpic1.png",
"store_name": "movies"
}
现在这里的问题是我有 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)->查找
然而,这没有奏效。
有人可以帮我一把谢谢吗
看看这个例子:http://php.net/manual/en/mongocollection.group.php