1 | <?php |
||
14 | abstract class BatchOperation implements \Countable |
||
15 | { |
||
16 | /** |
||
17 | * Batch operation class name. Must be override in child classes |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $batchClass; |
||
21 | |||
22 | /** |
||
23 | * @var Collection |
||
24 | */ |
||
25 | protected $collection; |
||
26 | |||
27 | /** |
||
28 | * Batch operation instance |
||
29 | * @var \MongoWriteBatch |
||
30 | */ |
||
31 | private $batch; |
||
32 | |||
33 | /** |
||
34 | * Amount of operations in batch operation |
||
35 | * @var int |
||
36 | */ |
||
37 | private $counter = 0; |
||
38 | |||
39 | /** |
||
40 | * Result of executed batch operation |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $result; |
||
44 | |||
45 | /** |
||
46 | * @param Collection $collection |
||
47 | * @param int|string $writeConcern Write concern. Default is 1 (Acknowledged). |
||
48 | * More info at http://php.net/manual/ru/mongo.writeconcerns.php |
||
49 | * @param int $timeout Timeout for write concern. Default is 10000 milliseconds |
||
50 | * @param bool $ordered Set to true if MongoDB must apply this batch in order (sequentially, |
||
51 | * one item at a time) or can rearrange it. Defaults to TRUE |
||
52 | */ |
||
53 | public function __construct( |
||
83 | |||
84 | protected function init() {} |
||
85 | |||
86 | protected function add($data) |
||
92 | |||
93 | public function execute($writeConcern = null, $timeout = null, $ordered = null) |
||
113 | |||
114 | public function getResult() |
||
118 | |||
119 | public function count() |
||
123 | } |
||
124 |