php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #60991 Added the continueOnError flag to batch_insert
Submitted: 2012-02-06 13:17 UTC Modified: 2013-07-22 14:37 UTC
From: litvinok at gmail dot com Assigned:
Status: Not a bug Package: mongo (PECL)
PHP Version: 5.3.10 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: litvinok at gmail dot com
New email:
PHP Version: OS:

 

 [2012-02-06 13:17 UTC] litvinok at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/mongocollection.batchinsert
---

Now, we can use following option:
"PHP-233: Added the continueOnError flag to batch_insert()."

It insterts all documents, except one's that were excluded.

Test script:
---------------
$object = $db->selectCollection('c');
$object->drop();

$doc1 = array(
'_id' => new MongoId('4cb4ab6d7addf98506010001'),
'id' => 1,
'desc' => "ONE",
);
$doc2 = array(
'_id' => new MongoId('4cb4ab6d7addf98506010002'),
'id' => 2,
'desc' => "TWO",
);
$doc3 = array(
'_id' => new MongoId('4cb4ab6d7addf98506010002'),
'id' => 3,
'desc' => "THREE",
);
$doc4 = array(
'_id' => new MongoId('4cb4ab6d7addf98506010004'),
'id' => 4,
'desc' => "FOUR",
);

$object->batchInsert(array($doc1, $doc2, $doc3, $doc4), array('continueOnError' => true));

Actual result:
--------------
array(3) {
["_id"]=>
object(MongoId)#%d (1) {
["$id"]=>
string(24) "4cb4ab6d7addf98506010001"
}
["id"]=>
int(1)
["desc"]=>
string(3) "ONE"
}
array(3) {
["_id"]=>
object(MongoId)#%d (1) {
["$id"]=>
string(24) "4cb4ab6d7addf98506010002"
}
["id"]=>
int(2)
["desc"]=>
string(3) "TWO"
}
array(3) {
["_id"]=>
object(MongoId)#%d (1) {
["$id"]=>
string(24) "4cb4ab6d7addf98506010004"
}
["id"]=>
int(4)
["desc"]=>
string(4) "FOUR"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-14 19:36 UTC] derick@php.net
Why exactly is this a bug? Your expected output is exactly what it should be.
 [2013-07-22 14:37 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2013-07-22 14:37 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 15:01:27 2025 UTC