PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

The MongoProtocolException class | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

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

<?php
$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

忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「The MongoProtocolException class」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | The MongoProtocolException class」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: