MongoClient
、MongoDB
、MongoCollectionクラス
は、MongoDB\Driver\Managerクラス
により廃止されました。
動作上の変更点などがこちらのChanges from our legacy mongo extension
に書かれているので、確認しておくと良いでしょう。
Changes from our legacy mongo extension
Most significantly, the legacy driver's MongoClient, MongoDB, and MongoCollection classes have been obsoleted by the MongoDB\Driver\Manager class, which is the new gateway for connecting and executing queries, commands, and write operations.
Two significant behavioral changes between the legacy and new driver are:
- Unlike MongoCursor in the legacy driver, which had pre- and post-executed states and could be rewound to re-execute a query, MongoDB\Driver\Cursor always corresponds to results of an executed command or query and may only be iterated once.
- The new driver unserializes BSON documents (both root and embedded) as stdClass objects by default (compared to PHP arrays in the legacy driver). This behavior may be customized via the setTypeMap() method on MongoDB\Driver\Cursor and is discussed in more detail in the BSON persistence documentation.
Note: mongo-php-library does provide client, database, and collection classes, which resemble the like-named classes in our legacy driver; however, while these new classes are mostly equivalent, some command helper methods have not been reimplemented and public APIs in the library have changed to ensure compatibility with current specifications such as the CRUD API.
また、PHP公式マニュアルのMongoClientクラスのページにも、MongoClientクラス
が定義されている拡張モジュールが非推奨である旨が書かれており、その代替としてMongoDB\Driver\Managerクラス
が紹介されています。
警告
このクラスを定義している拡張モジュールは非推奨です。 かわりに MongoDB 拡張モジュールを使うべきです。 このクラスの代替として、以下が使えます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/04/14 23:00