MongoDB组按键PHP
好的,我的MongoDB中有一个收藏 这是一个样本我的钥匙在这里 公司 现在的问题是我有4行/收集hoyts,我需要将它们分组 我当前的代码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; /
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);
}