title: How to use aggregate function in Mongodb?
body: <p>I have upgraded php5 to php7. If I use mongoClient for mongodb connection it shows error.So I used following command.</p>
  
  <p><code>$manager = new MongoDB\Driver\Manager("mongodb://".MONGOHOST.":27017");</code></p>
  
  <p>By using above command I can able to connect db.Now problem is In php5, I used aggregate function.It doesn't support in php7. Code used in php5 mentioned  below..</p>
  
  <p>for db connection</p>
  
  <p><code>$m = new MongoClient('mongodb://'.MONGOHOST.'', array('username' =&gt; MONGOUSER, 'password' =&gt; MONGOPASS, 'db'=&gt; MONGODB ));
  $db = $m-&gt;selectDB(MONGODB);</code></p>
  
  <p>to retrieve value from db:</p>
  
  <pre><code>$ops = array(
          array(
               '$match'=&gt;array(
                  "datetime"=&gt;array('$gte'=&gt;$start,'$lte'=&gt;$end)
                  )
              ),
          array(
              '$group' =&gt; array(
                  "_id" =&gt; array("slotid" =&gt; '$slotid',"bidder" =&gt; '$bidder',"viewerid" =&gt; '$viewerid',"mediatype"=&gt;'$mediatype'),"total" =&gt; array('$sum' =&gt; 1),"sitename" =&gt;array('$addToSet' =&gt; '$sitename'),"aid" =&gt;array('$addToSet' =&gt; '$accountid'),
                  ),
              ),
          );
  </code></pre>
  
  <p>$reqbids = $db->requestbids->aggregate($ops);</p>
  
  <p>How to do this is using mongo driver..I have searching 2 days,but didn't find the solution.</p>