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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
6 + 29 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 14:01:31 2024 UTC