1 | <?php |
||
9 | class DiffStorageStore implements DiffStorageStoreInterface { |
||
10 | /** @var PDO */ |
||
11 | private $pdo; |
||
12 | /** @var PDOStatement */ |
||
13 | private $insertStmt; |
||
14 | /** @var PDOStatement */ |
||
15 | private $selectStmt; |
||
16 | /** @var PDOStatement */ |
||
17 | private $updateStmt; |
||
18 | /** @var string */ |
||
19 | private $storeA; |
||
20 | /** @var string */ |
||
21 | private $storeB; |
||
22 | /** @var int */ |
||
23 | private $counter = 0; |
||
24 | /** @var callable */ |
||
25 | private $duplicateKeyHandler; |
||
26 | /** @var array */ |
||
27 | private $converter; |
||
28 | /** @var string[] */ |
||
29 | private $keys; |
||
30 | /** @var string[] */ |
||
31 | private $valueKeys; |
||
32 | |||
33 | /** |
||
34 | * @param PDO $pdo |
||
35 | * @param string $keySchema |
||
36 | * @param string $valueSchema |
||
37 | * @param string[] $keys |
||
38 | * @param string[] $valueKeys |
||
39 | * @param array $converter |
||
40 | * @param string $storeA |
||
41 | * @param string $storeB |
||
42 | * @param callable $duplicateKeyHandler |
||
43 | */ |
||
44 | public function __construct(PDO $pdo, $keySchema, $valueSchema, array $keys, array $valueKeys, array $converter, $storeA, $storeB, $duplicateKeyHandler) { |
||
56 | |||
57 | /** |
||
58 | * @param array $data |
||
59 | * @param array $translation |
||
60 | * @param callable $duplicateKeyHandler |
||
61 | */ |
||
62 | public function addRow(array $data, array $translation = null, $duplicateKeyHandler = null) { |
||
98 | |||
99 | /** |
||
100 | * @param Traversable|array $rows |
||
101 | * @param array $translation |
||
102 | * @param callable $duplicateKeyHandler |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function addRows($rows, array $translation = null, $duplicateKeyHandler = null) { |
||
111 | |||
112 | /** |
||
113 | * Returns true whenever there is any changed, added or removed data available |
||
114 | */ |
||
115 | public function hasAnyChanges() { |
||
126 | |||
127 | /** |
||
128 | * Get all rows, that are present in this store, but not in the other |
||
129 | * |
||
130 | * @return Generator|DiffStorageStoreRow[] |
||
131 | */ |
||
132 | public function getNew() { |
||
150 | |||
151 | /** |
||
152 | * Get all rows, that have a different value hash in the other store |
||
153 | * |
||
154 | * @return Generator|DiffStorageStoreRow[] |
||
155 | */ |
||
156 | public function getChanged() { |
||
174 | |||
175 | /** |
||
176 | * @return Generator|DiffStorageStoreRow[] |
||
177 | */ |
||
178 | public function getNewOrChanged() { |
||
196 | |||
197 | /** |
||
198 | * Get all rows, that are present in the other store, but not in this |
||
199 | * |
||
200 | * @return Generator|DiffStorageStoreRow[] |
||
201 | */ |
||
202 | public function getMissing() { |
||
220 | |||
221 | /** |
||
222 | * @return $this |
||
223 | */ |
||
224 | public function clearAll() { |
||
229 | |||
230 | /** |
||
231 | * @param string $query |
||
232 | * @return Generator|DiffStorageStoreRow[] |
||
233 | */ |
||
234 | private function query($query) { |
||
244 | |||
245 | /** |
||
246 | * @return Traversable|array[] |
||
247 | */ |
||
248 | public function getIterator() { |
||
268 | |||
269 | /** |
||
270 | * @param array $data |
||
271 | * @param array $translation |
||
272 | * @return array |
||
273 | */ |
||
274 | private function translate(array $data, array $translation = null) { |
||
287 | |||
288 | /** |
||
289 | * @return int |
||
290 | */ |
||
291 | public function count() { |
||
305 | |||
306 | /** |
||
307 | * @param array $localData |
||
308 | * @param array $foreignData |
||
309 | * @return DiffStorageStoreRow |
||
310 | */ |
||
311 | private function instantiateRow(array $localData = null, array $foreignData = null) { |
||
314 | } |
||
315 |