How to set timeout to infinite to avoid MongoCursorTimeoutException in php
MongoCursor::$timeout = -1;
type above line in your php code. this set timeout for all queries .best regard,
Here's documentation for setting the timeout on a cursor.
$cursor = $collection->find()->timeout(n);
The command
method does not return a cursor it returns an array.
If you take a look at the documentation for the command method, you'll see that it's actually just a wrapper for the following:
public function command($data) { return $this->selectCollection('$cmd')->findOne($data);}
That should get you going in the right direction.
The PHP driver supports a second argument in the command method to set the timeout.
This means you should do the following:
$value = $db->command( array('distinct' => $collection, 'key' => 'uid', 'query' => $criteria), array('timeout' => 10000000000));
This should solve your problem!