Наш чат в Telegram для обмена идеями, проектами, мыслями, людьми в сфере ИТ г.Ростова-на-Дону: @it_rostov

The MongoProtocolException class

(PECL mongo >= 1.5.0)


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.

Обзор классов

MongoProtocolException extends MongoException {
/* Наследуемые свойства */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;


Пример #1 Catching MongoProtocolException

Running the following example against MongoDB prior to 2.6.0 will throw an MongoProtocolException

$mc = new MongoClient("localhost");
$c = $mc->selectCollection("test", "test");
try {
    $batch = new MongoInsertBatch($c);
} catch(MongoProtocolException $e) {
    echo $e->getMessage();

Результатом выполнения данных примеров будет что-то подобное:

Current primary does not have a Write API

User Contributed Notes

There are no user contributed notes for this page.

To Top

Смотрите также:
Описание на ru2.php.net
Описание на php.ru