I am trying to write a PHP (Mongo) query from SQL in which I have SUM() but I am not sure my syntax is correct. Can someone enlighten me?
SQL:
$cmd = "SELECT SUM(m_length) FROM pkt_tbl WHERE m_time>=" . $time. " AND m_buffer_latency<=" . $time;
Mongodb Query:
$find_projection= aggregate(array('$group'=>array('$sum'=>'$m_length')));
$result = $table -> command($find_projection);
Can I use array_sum is the $result or is there anyway I can use $SUM (Aggregate) in this case. Any help would be appreciated.
Thanks