The MongoProtocolException class
(PECL mongo >= 1.5.0)
Introduction
When talking to MongoDB 2.6.0, and later, certain operations (such as writes) may throw MongoProtocolException when the response from the server did not make sense - for example during network failure (we could read the entire response) or data corruption.
This exception is also thrown when attempting to talk newer protocols then the server supports, for example using the MongoWriteBatch when talking to a MongoDB server prior to 2.6.0.
Class synopsis
Examples
Example #1 Catching MongoProtocolException
Running the following example against MongoDB prior to 2.6.0 will throw an MongoProtocolException
<?php
$mc = new MongoClient("localhost");
$c = $mc->selectCollection("test", "test");
try {
$batch = new MongoInsertBatch($c);
} catch(MongoProtocolException $e) {
echo $e->getMessage();
}
?>
The above examples will output something similar to:
Current primary does not have a Write API
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- MongoDB
- The MongoException class
- The MongoResultException class
- The MongoCursorException class
- The MongoCursorTimeoutException class
- The MongoConnectionException class
- The MongoGridFSException class
- The MongoDuplicateKeyException class
- The MongoProtocolException class
- The MongoExecutionTimeoutException class
- The MongoWriteConcernException class
Коментарии
404 Not Found