How do you limit the number of documents returned?

<?php
// c-r-u-d-ops-query-mods-find-limit-one.php

// db.customers.find({acct_balance:{$gt:100000}},{firstName:1,surname:1,_id:0}).limit(1)

// query
$query      = array('acct_balance' => array('$gt' => 100000));
$client     = new MongoClient(); // connect
$db         = $client->selectDB('mydb');
$collection = $db->selectCollection('customers');
$cursor     = $collection->find($query)->limit(1);

// results
var_dump($cursor->getNext());





>>
 


+ o -