php - How to solve Fatal error: Class 'MongoClient' not found? -
i using windows 10 64 bit, xampp 3.2.2, php 5.6.30, php extension build vc11, mongodb server version: 3.4.3.
i getting error "fatal error: class 'mongoclient' not found in d:\xampp\htdocs\test\test1.php on line 4".
here code using
code
<?php // connect $m = new mongoclient(); // select database $db = $m->cabin; // select collection (analogous relational database's table) $collection = $db->user; // find in collection $cursor = $collection->find(); // iterate through results foreach ($cursor $document) { echo $document["title"] . "\n"; } ?>
i have added dll file in folder (d:\xampp\php\ext)
, added extension in php.ini (d:\xampp\php)
"extension=php_mongodb.dll". issue not solved.
mongodb (mongo db working)
user@desktop-jcdjq65 mingw64 /d $ mongo mongodb shell version v3.4.3 connecting to: mongodb://127.0.0.1:27017 mongodb server version: 3.4.3 use cabin switched db cabin show tables bmessages booking cabins club country customer email facilities land mschool region role rooms settings tempuser tour user userold visit
mongoclient
belongs long deprecated mongo extension. new mongodb extension uses manager connect database, e.g.
$m = new mongodb\driver\manager("mongodb://localhost:27017"); $cursor = $manager->executequery("cabin.user", new mongodb\driver\query([])); foreach ($cursor $document) { echo $document["title"] . "\n"; }
or use of higher level abstraction libraries. e.g. https://github.com/mongodb/mongo-php-library provides interface similar legacy driver.
Comments
Post a Comment