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
35
votes
12 answers

Installing the PHP 7 MongoDB Client/Driver?

I am very eager to start working with PHP 7 however one issue is getting in the way... I primarily use MongoDB for the database, and the problem is that I don't know how to install the MongoDB driver/client for PHP 7. My current installation is PHP…
Vladimir Fazilov
  • 381
  • 1
  • 4
  • 6
12
votes
1 answer

Aggregation $lookup with $let is not working

I have a collection TblStudent in mongodb like { "_id": ObjectId("5baa85041d7859f40d000029"), "Name": "John Doe", "RollNo": 12, "Class": "Ist" .... } I have another collection TblRoute like { …
11
votes
4 answers

MongoDB no suitable servers found

I'm having trouble connecting to a replica set. [MongoDB\Driver\Exception\ConnectionTimeoutException] No suitable servers found…
Bernardo
  • 475
  • 1
  • 5
  • 19
10
votes
7 answers

PHP MongoDB - Use of the aggregate command without the cursor option is deprecated. What?

I have updated mongo and now in the log the following error appears: Use of the aggregate command without the cursor option is deprecated Mongo says that I should put a second REQUIRED parameter to aggregate function, because my current usage is…
ephramd
  • 561
  • 2
  • 15
  • 41
8
votes
6 answers

How to download Mongodb 3.0?

I have used PHP Version 5.3, So i need to Download MongoDB 3.0 and PHP Driver version 1.6 how to download older version (3.0) of MongoDB and PHP Driver.. And also i want use PHP composer and already i have used Composer for like composer require…
Balakumar B
  • 770
  • 5
  • 17
  • 41
5
votes
0 answers

How to disable persistent connection between php and mongodb?

When I use driver MongoDB\Driver in PHP7, php always creates lots of connections with mongo. And I can't close the connection by myself, because MongoDB\Driver hasn't a close() method. How to disable persistent connection? Or how to configure it?
xinHAOr
  • 141
  • 1
  • 5
4
votes
2 answers

Project inside pipeline of lookup with local field and foriegn field not working

I have written below lines of code for getting some specific fields inside lookup like $pipeline = array( array( '$match' => $query ), array( '$lookup' => array( …
4
votes
4 answers

How to set limit() into MongoQuery Using PHP?

I have to use Mongodb with php, and tried to get data from mongocollection using php. the follwing mongoquery with php return record successfully. but i want to set limit for following query. PHP Code: $query = array("\$and"=>array(array('fld'=>…
Balakumar B
  • 770
  • 5
  • 17
  • 41
4
votes
0 answers

getting a generic BulkWrite error in MongoDB / Laravel

So I have the following artisan command controller:
neubert
  • 15,947
  • 24
  • 120
  • 212
3
votes
2 answers

How to use "MongoDB\Driver\Query($filter, $options)"?

I m trying to make a query in PHP with the MongoDB\Driver\Query class but with the doc in php.net I didn't really understand how to make it work. I would like to return a JSON object with all data of my collection. This for a function PHP running…
Vaaalaa
  • 41
  • 2
3
votes
3 answers

No suitable servers found (`serverSelectionTryOnce` set): [connection timeout calling ismaster on '10.0.0.106:27017']

i have this issue with laravel project use mongoDB ConnectionTimeoutException in Collection.php line 192: No suitable servers found (`serverSelectionTryOnce` set): [connection timeout calling ismaster on '10.0.0.106:27017'] i did service ngnix…
flower
  • 989
  • 4
  • 16
  • 34
3
votes
1 answer

Mongo Db aggregate $lookup returns empty array

when trying to "JOIN" operation with $lookup but results count is ok but "as" document is empty I have two collections and i need to get user details from subscribercol with user_id in employer_jobscol subscribercol { "_id" :…
VishnuKumar Pv
  • 167
  • 1
  • 13
3
votes
1 answer

how to sort result of lookup in mongodb

I want to join two collections and sort the date field in the foreign table and then have group the fields to get only one record from recent date for each device as below $collection = $this->db->dv_device; $result_data = …
3
votes
0 answers

New MongoId() solution during migration from PHP 5.5 to in PHP 7

In PHP7 new MongoId() is not working and solution to get mongo id in php7 using below function var_dump(new MongoDB\BSON\ObjectId()), but I am using this in multiple files almost more than 200 files so I don't want manually edit all these files. So…
Anant Waykar
  • 662
  • 2
  • 8
  • 18
3
votes
2 answers

How to get cursor result count using the MongoDB PHP extension

The mongo PHP extension is deprecated in favour of the mongodb extension. This extension is used together with the mongo-php-library. In the old extension one could get the result count from the cursor using MongoCursor::count(). However, the new…
Sander Toonen
  • 3,463
  • 35
  • 54
1
2 3
11 12