views:

72

answers:

1

I would like to know if there is anyway I can "group by" my results with MongoDB/Php.

This is the code I'm using to display my rows:

$count = $col->find(array('order_id' => array('$gt' => '0')))->count();

I need to group them by order_id.

Apparently, we cannot do a count() on a group() as find()

WORKS: $countfind = $col->find()->count();

DOESN'T WORK: $countgroup = $col->group($keys)->count();

I need to count this groupby please.

Thanks for your help.

A: 

There's some detailed documentation on the Group command on their website.

There are some examples of Group using the PHP libarary here.

If your data set is really big, you may need to look at running map-reduces to "pre-group" this data.

Gates VP
Thank you, i'll try it
Steffi