rrubiorr81
rrubiorr81

Reputation: 305

iterate all documents->_ids in mongodb, php

I'm currently doing this:

  $t_category = 781;
  $res = $collection->findOne(array("_id" => intval($t_category)));

this way i am getting only one category (it was just to try). How can I get all categories (documents->_ids) in php->mongo? A way I could iterate over all the documents in the collection. I have tried the find with no arguments. No luck. Any idea?

Upvotes: 0

Views: 687

Answers (1)

Colin M
Colin M

Reputation: 13348

Calling find with no arguments will return all items in the collection.

$results = $collection->find();

Upvotes: 1

Related Questions