Skip to content
Advertisement

MongoDB PHP Error: Warning: Undefined property: MongoDBDriverManager

I’m trying to use MongoDB on my local machine using the advice in this stack overflow. I’m using XAMPP on Windows 10, php version 8.01, and MongoDB extension 1.9.0.

It’s a very basic script that connects to MongoDB and tries to use one of the databases.

But I am still getting this warning:

JavaScript

This is my code:

JavaScript

How can I get rid of the warning and connect to the DB correctly?

Advertisement

Answer

First, you’re trying to access a property which doesn’t exists in MongoDBDriverManager class object.

Second, $db = $m->aws_inventories; works with MongoDBClient library.

Here are few example to get collections list or find all/specific document/s or insert/bulk insert, update a document or to perform a distinct query

Get all collections of aws_inventories:

JavaScript

Get all documents from a collection:

JavaScript

To perform distinct query:

JavaScript

To insert single/multiple document/s:

JavaScript

To update existing document/s: (Taken from executeUpdate example)

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement