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