@@ 237-248 (lines=12) @@ | ||
234 | $data = $this->pb->prepareInsertData($document); |
|
235 | ||
236 | // Set the initial version for each insert |
|
237 | if ($this->class->isVersioned) { |
|
238 | $versionMapping = $this->class->fieldMappings[$this->class->versionField]; |
|
239 | if ($versionMapping['type'] === 'int') { |
|
240 | $nextVersion = max(1, (int) $this->class->reflFields[$this->class->versionField]->getValue($document)); |
|
241 | $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersion); |
|
242 | } elseif ($versionMapping['type'] === 'date') { |
|
243 | $nextVersionDateTime = new \DateTime(); |
|
244 | $nextVersion = new \MongoDate($nextVersionDateTime->getTimestamp()); |
|
245 | $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersionDateTime); |
|
246 | } |
|
247 | $data[$versionMapping['name']] = $nextVersion; |
|
248 | } |
|
249 | ||
250 | $inserts[$oid] = $data; |
|
251 | } |
|
@@ 315-326 (lines=12) @@ | ||
312 | $data = $this->pb->prepareUpsertData($document); |
|
313 | ||
314 | // Set the initial version for each upsert |
|
315 | if ($this->class->isVersioned) { |
|
316 | $versionMapping = $this->class->fieldMappings[$this->class->versionField]; |
|
317 | if ($versionMapping['type'] === 'int') { |
|
318 | $nextVersion = max(1, (int) $this->class->reflFields[$this->class->versionField]->getValue($document)); |
|
319 | $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersion); |
|
320 | } elseif ($versionMapping['type'] === 'date') { |
|
321 | $nextVersionDateTime = new \DateTime(); |
|
322 | $nextVersion = new \MongoDate($nextVersionDateTime->getTimestamp()); |
|
323 | $this->class->reflFields[$this->class->versionField]->setValue($document, $nextVersionDateTime); |
|
324 | } |
|
325 | $data['$set'][$versionMapping['name']] = $nextVersion; |
|
326 | } |
|
327 | ||
328 | foreach (array_keys($criteria) as $field) { |
|
329 | unset($data['$set'][$field]); |