find() public method

Finds documents matching the query.
See also: http://docs.mongodb.org/manual/core/read-operations-introduction/
public find ( string $collectionName, array | object $filter = [], array $options = [] ) : MongoDB\Driver\Cursor
$collectionName string
$filter array | object Query by which to filter documents
$options array Additional options
return MongoDB\Driver\Cursor
Example #1
0
 public function find($collectionName, $filter = [], $sort = [], $limit = 0, $skip = 0, array $options = [])
 {
     $options += ['limit' => $limit, 'skip' => $skip, 'sort' => $sort];
     $result = $this->bridge->find($this->cName($collectionName), $filter, $options)->toArray();
     $data = [];
     /* @var $r BSONDocument */
     foreach ($result as $r) {
         $data[] = iterator_to_array($r->getIterator());
     }
     return $data;
 }
Example #2
0
 public function find($collectionName, $filter = [], $sort = [], $limit = 0, $skip = 0, array $options = [])
 {
     $options += ['limit' => $limit, 'skip' => $skip, 'sort' => $sort];
     return $this->bridge->find($this->cName($collectionName), $filter, $options);
 }