質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
MongoDB

MongoDBはオープンソースのドキュメント指向データベースの1つです。高性能で、多くのリトルエンディアンシステムを利用することができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

解決済

1回答

1187閲覧

phpでMongoDB\Clientを生成時 ’not found’になる

退会済みユーザー

退会済みユーザー

総合スコア0

MongoDB

MongoDBはオープンソースのドキュメント指向データベースの1つです。高性能で、多くのリトルエンディアンシステムを利用することができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2018/04/11 09:58

php5.6(cakephp3)でMongoDB\clientを使おうとして
「pecl install mongodb」でインストール、
「MongoDB 1.4.2」がphpinfo()で確認できたのですが

$client = new \MongoDB\Client("mongodb://localhost:27017");

**** Error: Class 'MongoDB\client' not found ***
となってしまいます。

ちなみに
$mongo = new \MongoDB\Driver\Manager("mongodb://localhost:27017");
これはOKです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

MongoClientMongoDBMongoCollectionクラスは、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 拡張モジュールを使うべきです。 このクラスの代替として、以下が使えます。

  • MongoDB\Driver\Manager

投稿2018/04/11 10:28

ninjya

総合スコア28

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2018/04/14 23:00

了解しました。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問