MongoDB and PHP - insert and update large PHP array
NickName:Subrat Basnet Ask DateTime:2011-10-29T23:51:34

MongoDB and PHP - insert and update large PHP array

I have a loop and each time the loop iterates, it adds a record to an array.

In my current model, I wait for the loop to finish completely and then insert that array into MongoDB and have not had problems with that until now.

Now my array size is starting to exceed 10 MB after the loop and I read that Mongo has a 4MB limit. And I do not want to store the whole array into memory while I wait for the loop to finish.

Ideally, I'd love to do an update within the loop on the same Mongo Id of the collection so that I do not need to store the array in the memory. However, it seems Mongo will not support if the collection size is over 4MB so I do not know how to go about it.

I read about GridFS but I do not see a way to insert arrays using it. Any ideas would be much appreciated.

Copyright Notice:Content Author:「Subrat Basnet」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/7939909/mongodb-and-php-insert-and-update-large-php-array

More about “MongoDB and PHP - insert and update large PHP array” related questions

MongoDB and PHP - insert and update large PHP array

I have a loop and each time the loop iterates, it adds a record to an array. In my current model, I wait for the loop to finish completely and then insert that array into MongoDB and have not had

Show Detail

Insert array in mongodb using php

how to insert inner array in mongodb using php I run this command in sheel then it runs db.domain_data.update({"email":"[email protected]","url.tlds":".com"},{'$addToSet':{"url.$.domain"

Show Detail

MongoDB\Driver\Manager php insert array json object

This is my simple Php. $manager = new MongoDB\Driver\Manager("mongodb://localhost:27017"); $bulk = new MongoDB\Driver\BulkWrite; I have this Array Json in a variable $obj = file_get_contents("link

Show Detail

php 7 mongodb collection insert

We've installed php mongo ext and then have the composer set up as well. https://github.com/alcaeus/mongo-php-adapter In my php code I've this: require_once 'vendor/autoload.php'; $m = new Mong...

Show Detail

How to insert array values(php) in MongoDB?

My contents of MongoDB(when i used find()) is like this: { "_id": ObjectId("50072b17b4a6de3b11000001"), "addresses": [ { "_id": ObjectId("

Show Detail

Insert data in MongoDB using PHP

I am on php 5.6 using WAMP and want to insert a document into MongoDB using PHP. I am doing it in this way: <?php require 'vendor/autoload.php'; $con = new MongoDB\Client("mongodb://

Show Detail

mongodb in php-insert array to mongo db collection

i use mongodb in php and have a problem to insert $subitems array to mongodb collection. php code: if($_SERVER["REQUEST_METHOD"] == "POST"){ $errors = array(); $alarm = array(); $ite...

Show Detail

MongoDB not insert in order with PHP Driver

There is a problem in inserting to MongoDB database. It is not insert to database in right order. We read the writing concern in MongoDB: http://www.php.net/manual/en/mongo.writeconcerns.php We use

Show Detail

Insert MongoDB ISODate PHP

I am using the following versions: PHP -> 5.6.11 MongoDB -> 3.2 MongoDB PHP Driver -> 1.1 When I was looking to install a MongoDB PHP driver here I noticed t...

Show Detail

MongoDB PHP, insert() not working

I'm trying to set up a simple MongoDB and insert some data. I have to use PHP and I am running the code on external server owned by my uniersity (it is obligatory for me, the server has everything ...

Show Detail