PHP Portal » PHP Handbuch » MongoCursor::timeout

Werbung

MongoCursor::timeout


(PECL mongo >=1.0.3)

MongoCursor::timeoutSets a client-side timeout for this query

Beschreibung

public MongoCursor MongoCursor::timeout ( int $ms )

Parameter-Liste

ms

The number of milliseconds for the cursor to wait for a response. By default, the cursor will wait forever.

Rückgabewerte

This cursor.

Beispiele

Beispiel #1 MongoCursor::timeout() example

A query where the cursor waits for one second for a response.

PHP Code
1
2
3
4
5
6
7
8
9
$cursor = $collection->find()->timeout(1000); try { foreach ($cursor as $value) { print_r($value); } } catch(MongoCursorTimeoutException $e) { echo "query took too long!"; }

Fehler/Exceptions

Causes methods that fetch results to throw MongoCursorTimeoutExceptions if the query takes longer than the number of milliseconds specified.