Questions tagged [php-mongodb]

MongoDB driver: PHP Extension for Mongo DB

Unlike the mongo extension, this extension supports both PHP and HHVM and is developed atop the » libmongoc and » libbson libraries. It provides a minimal API for core driver functionality: commands, queries, writes, connection management, and BSON serialization.

Userland PHP libraries that depend on this extension may provide higher level APIs, such as query builders, individual command helper methods, and GridFS. Application developers should consider using this extension in conjunction with the » MongoDB PHP library, which implements the same higher level APIs found in MongoDB drivers for other languages. This separation of concerns allows the driver to focus on essential features for which an extension implementation is paramount for performance.

168 questions
2
votes
2 answers

how to get older versions of mongodb?

So I did sudo apt-get install php5-mongo and when I do composer require "mongodb/mongodb=~1.0.0" I get this: Problem 1 - Installation request for mongodb/mongodb ~1.0.0 -> satisfiable by mongodb/mongodb[1.0.0]. - mongodb/mongodb 1.0.0…
neubert
  • 15,947
  • 24
  • 120
  • 212
2
votes
2 answers

Using "Legacy" MongoDB Driver with PHP7

Is there a way to use the Legacy Mongo PHP Driver from PECL with PHP7? Maybe unofficial fork with PHP7 support or compile/modification instruction...
1
vote
1 answer

Install PECL mongodb php driver extension in a multiphp fpm environment of CentOS 7

I am trying to install pecl mongodb php driver extension in a multi php (fpm) environment of a CentOS (release 7.5) server. I have three PHP versions configured as: systemctl enable php72-php-fpm (default) systemctl enable php80-php-fpm systemctl…
sariDon
  • 7,782
  • 2
  • 16
  • 27
1
vote
1 answer

PHP mongo filter subdocument

I want to use an aggregator for filtering the subdocument. I want to show only 25 elements in "Message" subdocument matching sType ="xdc" only and search in "type". It should not shown others soubdocument other than match. [0] => Array( [_id] =>…
Shail
  • 1,565
  • 11
  • 24
1
vote
1 answer

PHP Mongo Multiple "AND" using "find" method

I am trying to fetch data with "AND" condition but its not matching all conditions. I want to fetch result only when all conditions match. My conditions are :- $and1 = array( '$and' => array( array( "users.23315" => array(…
Shail
  • 1,565
  • 11
  • 24
1
vote
1 answer

"sudo pecl install mongodb" not working on macOS

I am trying to install MongoDB PHP extension on macOS Catalina v10.15.7 by running the following command, sudo pecl install mongodb But it is throwing below error at the end, Build process completed successfully Installing…
1
vote
1 answer

write mongodb driver query with php fetch records from embedded array

Filter item from records array it should only return two items because records.score = 100 having only two items instead this it return me all the records. Can you please help on this thanks. I have multiple records wherein I would like to fetch…
simon
  • 359
  • 1
  • 14
1
vote
0 answers

Namespace MongoDB\BSON and MongoDB\Drivers are missing

I am learning PHP REST + MongoDb. I had installed mongodb PHP library using "composer require mongodb/mongodb". But I am not able to use any type from MongoDB\BSON\XXXXX. Visual studio code says *MongoDB\BSON* is not even a package. I tried "use…
SatbirSingh
  • 198
  • 1
  • 11
1
vote
1 answer

how can i apply sorting in string in mongodb

this is my sample document { "string" : "class.chapter.1.topic.10" } how can I sort this string according to "chapter.anynumber.topic.anynumber"
1
vote
1 answer

Is it needed to install MongoDB locally to connect a PHP project with a remote MongoDB server?

I am trying to run a PHP project which is connected to a remote MongoDB server on my local machine. I already made sure that the PHP-mongo.dll extension is installed. Now, is it necessary for me to install MongoDB locally as well?
DDD
  • 13
  • 3
1
vote
2 answers

how can I drop user from "system.users" using mongodb and PHP?

I need a small help. I can not delete "System.User" user from MongoDB database. /*Remove Tenent DB*/ function RemoveTenentDB($mydb){ error_reporting(0); $connection_string = Config::get('database.creator-tenant-uri'); $m = new…
HEMAL
  • 420
  • 3
  • 14
1
vote
0 answers

Problem using PHP MongoDB extension to connect over SSL/TLS: ConnectionTimeoutException: No suitable servers found (`serverSelectionTryOnce` set)

I'm experiencing issue when trying to connect to my MongoDB server, which requires SSL/TLS, using the PHP mongodb extension: PHP Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found…
Frederick Zhang
  • 3,593
  • 4
  • 32
  • 54
1
vote
2 answers

PHP Mongodb Count Result

I'm performing a simple request to my MongoDB in php. It looks like this: $result = $this->myMongoClient->myCollection->find([ 'param_1' => $param_1, 'param_2' => $param_2, ]); This returns a MongoDB\Driver\Cursor object. I need the count…
Markus
  • 1,909
  • 4
  • 26
  • 54
1
vote
1 answer

What's the correct way to check if a collection exists?

Previously I was checking if a collection exists by querying the namespaces. Roughly like this, to check if "foo.bar" exists: return 1 === $client->selectCollection('foo','system.namespaces'); ->count(['name'=>'bar']); As this…
Tim
  • 8,036
  • 2
  • 36
  • 52
1
vote
1 answer

Exception "waiting for replication timed out" received for MongoDB Bulk Write operation

We have two servers for MongoDB servers, one is primary, the other is configured as replica. We use PHP to bulk write a list of updates to MongoDB. From the server logs, we do some a small amount of exceptions of "waiting for replication timed out"…
leon
  • 10,085
  • 19
  • 60
  • 77
1 2
3
11 12