Skip to content

Commit 266b7e9

Browse files
committed
PHPLIB-62: Its called BulkWrite now
1 parent bb7452f commit 266b7e9

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/Collection.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use MongoDB\Driver\Query;
88
use MongoDB\Driver\ReadPreference;
99
use MongoDB\Driver\Result;
10-
use MongoDB\Driver\WriteBatch;
10+
use MongoDB\Driver\BulkWrite;
1111
use MongoDB\Driver\WriteConcern;
1212

1313
class Collection
@@ -287,7 +287,7 @@ public function getBulkOptions()
287287
}
288288

289289
/**
290-
* Adds a full set of write operations into a batch and executes it
290+
* Adds a full set of write operations into a bulk and executes it
291291
*
292292
* The syntax of the $bulk array is:
293293
* $bulk = [
@@ -337,7 +337,7 @@ public function bulkWrite(array $bulk, array $options = array())
337337
{
338338
$options = array_merge($this->getBulkOptions(), $options);
339339

340-
$batch = new WriteBatch($options["ordered"]);
340+
$bulk = new BulkWrite($options["ordered"]);
341341

342342
foreach ($bulk as $n => $op) {
343343
foreach ($op as $opname => $args) {
@@ -347,7 +347,7 @@ public function bulkWrite(array $bulk, array $options = array())
347347

348348
switch ($opname) {
349349
case "insertOne":
350-
$batch->insert($args[0]);
350+
$bulk->insert($args[0]);
351351
break;
352352

353353
case "updateMany":
@@ -356,7 +356,7 @@ public function bulkWrite(array $bulk, array $options = array())
356356
}
357357
$options = array_merge($this->getWriteOptions(), isset($args[2]) ? $args[2] : array(), array("limit" => 0));
358358

359-
$batch->update($args[0], $args[1], $options);
359+
$bulk->update($args[0], $args[1], $options);
360360
break;
361361

362362
case "updateOne":
@@ -368,7 +368,7 @@ public function bulkWrite(array $bulk, array $options = array())
368368
throw new \InvalidArgumentException("First key in \$update must be a \$operator");
369369
}
370370

371-
$batch->update($args[0], $args[1], $options);
371+
$bulk->update($args[0], $args[1], $options);
372372
break;
373373

374374
case "replaceOne":
@@ -380,25 +380,25 @@ public function bulkWrite(array $bulk, array $options = array())
380380
throw new \InvalidArgumentException("First key in \$update must NOT be a \$operator");
381381
}
382382

383-
$batch->update($args[0], $args[1], $options);
383+
$bulk->update($args[0], $args[1], $options);
384384
break;
385385

386386
case "deleteOne":
387387
$options = array_merge($this->getWriteOptions(), isset($args[1]) ? $args[1] : array(), array("limit" => 1));
388-
$batch->delete($args[0], $options);
388+
$bulk->delete($args[0], $options);
389389
break;
390390

391391
case "deleteMany":
392392
$options = array_merge($this->getWriteOptions(), isset($args[1]) ? $args[1] : array(), array("limit" => 0));
393-
$batch->delete($args[0], $options);
393+
$bulk->delete($args[0], $options);
394394
break;
395395

396396
default:
397397
throw new \InvalidArgumentException(sprintf("Unknown operation type called '%s' (operation#%d)", $opname, $n));
398398
}
399399
}
400400
}
401-
return $this->manager->executeWriteBatch($this->ns, $batch, $this->wc);
401+
return $this->manager->executeBulkWrite($this->ns, $bulk, $this->wc);
402402
}
403403

404404
/**
@@ -415,9 +415,9 @@ public function insertOne(array $document)
415415
{
416416
$options = array_merge($this->getWriteOptions());
417417

418-
$batch = new WriteBatch($options["ordered"]);
419-
$id = $batch->insert($document);
420-
$wr = $this->manager->executeWriteBatch($this->ns, $batch, $this->wc);
418+
$bulk = new BulkWrite($options["ordered"]);
419+
$id = $bulk->insert($document);
420+
$wr = $this->manager->executeBulkWrite($this->ns, $bulk, $this->wc);
421421

422422
return new InsertResult($wr, $id);
423423
}
@@ -430,9 +430,9 @@ final protected function _delete($filter, $limit = 1)
430430
{
431431
$options = array_merge($this->getWriteOptions(), array("limit" => $limit));
432432

433-
$batch = new WriteBatch($options["ordered"]);
434-
$batch->delete($filter, $options);
435-
return $this->manager->executeWriteBatch($this->ns, $batch, $this->wc);
433+
$bulk = new BulkWrite($options["ordered"]);
434+
$bulk->delete($filter, $options);
435+
return $this->manager->executeBulkWrite($this->ns, $bulk, $this->wc);
436436
}
437437

438438
/**
@@ -475,9 +475,9 @@ protected function _update($filter, $update, $options)
475475
{
476476
$options = array_merge($this->getWriteOptions(), $options);
477477

478-
$batch = new WriteBatch($options["ordered"]);
479-
$batch->update($filter, $update, $options);
480-
return $this->manager->executeWriteBatch($this->ns, $batch, $this->wc);
478+
$bulk = new BulkWrite($options["ordered"]);
479+
$bulk->update($filter, $update, $options);
480+
return $this->manager->executeBulkWrite($this->ns, $bulk, $this->wc);
481481
}
482482

483483
/**

0 commit comments

Comments
 (0)