2012-06-19 72 views
0

好了,我有一個集合在我的MongoDBMongoDB的集團通過重點PHP

這裏是一個樣本在這裏我的關鍵是

公司

{ 
    "_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); 

    } 

我嘗試使用

組($鍵) - >找到

但沒有奏效。

可能有人給我一個手感謝

回答