Reputation: 6656
The code is like this, and the limit & sort have no effect, the query returns all the records that fit the filter.
$mongo = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$query = new MongoDB\Driver\Query( ['isSent' => false] );
$options = array('sort' => array('priority', 1), 'limit' => 10 );
$dt = $m->executeQuery("db.emails", $query, $options);
foreach($dt as $row) {
// do something
}
Am I missing something?
Upvotes: 0
Views: 249
Reputation: 10918
Try this instead:
$query = new MongoDB\Driver\Query( ['isSent' => false], ['sort' => ['priority' => 1], 'limit' => 10]);
$dt = $m->executeQuery("db.emails", $query);
Upvotes: 1