Esempio n. 1
0
 /**
  * Store document
  *
  * @param Document $document
  * @return void
  */
 protected function storeDocument(Document $document)
 {
     $lastRevision = $this->getLastRevisionSilent($document->_id);
     $this->data[$document->_id][$document->_rev] = $document;
     if ($this->revisionCalculator->getSequence($document->_rev) === $this->revisionCalculator->getSequence($lastRevision)) {
         $this->conflictDecider->select($document, $this->data[$document->_id][$lastRevision]);
     }
     $sequence = count($this->updates) + 1;
     $this->updates[$sequence] = new Update($sequence, $document->_id, array(new Revision($document->_rev)));
 }
Esempio n. 2
0
 /**
  * Store document
  *
  * @param Document $document
  * @return void
  */
 protected function storeDocument(Document $document)
 {
     $query = $this->database->prepare("INSERT INTO document (d_id, d_revision, d_document) VALUES (:id, :revision, :document);");
     $query->execute(array('id' => $document->_id, 'revision' => $document->_rev, 'document' => serialize($document)));
     $lastRevision = $this->getLastRevisionSilent($document->_id);
     if ($this->revisionCalculator->getSequence($document->_rev) === $this->revisionCalculator->getSequence($lastRevision)) {
         $this->conflictDecider->select($document, $this->getDocument($document->_id, $lastRevision));
     }
     $sequence = $this->getUpdateSequence() + 1;
     $query = $this->database->prepare("INSERT INTO document_update (du_sequence, d_id, d_revision) VALUES (:sequence, :id, :revision);");
     $query->execute(array('sequence' => $sequence, 'id' => $document->_id, 'revision' => $document->_rev));
 }