[PHP] How to “Group By” with MongoDB

1,423 views
Skip to first unread message

Roch Delsalle

unread,
Jul 12, 2010, 9:52:46 AM7/12/10
to mongodb-user
Hi,

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.

Thanks for your help.

Tony Hannan

unread,
Jul 12, 2010, 4:13:11 PM7/12/10
to mongod...@googlegroups.com
See http://www.mongodb.org/display/DOCS/Aggregation#Aggregation-Group.
I don't know the particulars for PHP but I bet you can figure it out by looking at the code.

Cheers,
Tony


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Kristina Chodorow

unread,
Jul 12, 2010, 7:11:18 PM7/12/10
to mongod...@googlegroups.com
There are some PHP-specific group examples at http://php.net/manual/en/mongocollection.group.php
Reply all
Reply to author
Forward
0 new messages