getVersion() public method

Gets the Version
public getVersion ( ) : integer
return integer
Example #1
0
 /**
  * Update a Record
  *
  * @param Record $record
  *
  * @return RecordUpdate|Record
  */
 public function recordUpdate(Record $record)
 {
     $result = $this->getTransport()->execute('recordUpdate', ['rid' => $record->getRid(), 'record' => $record, 'record_version' => $record->getVersion()]);
     $this->setFetchClass(false);
     return $result;
 }
 public function extractRecord(Record &$record)
 {
     // prepair data:
     $rid = $record->getRid();
     $recordData = $record->getOData();
     $recordData['@rid'] = $this->IDtoRid($rid);
     $recordData['@version'] = $record->getVersion();
     $recordData['@class'] = $record->getOClass();
     foreach ($recordData as $key => $value) {
         if (is_a($value, 'DateTime')) {
             $value = $value->format('Y-m-d H:i:s');
             $recordData[$key] = $value;
         } else {
             if (is_a($value, 'PhpOrient\\Protocols\\Binary\\Data\\Record')) {
                 $recordData[$key] = $this->extractRecord($value);
             } else {
                 if (is_array($value)) {
                     $embeddedData = [];
                     foreach ($value as $childRec) {
                         // EMBEDDEDSET, EMBEDDEDLIST, EMBEDDEDMAP
                         if (is_a($childRec, 'PhpOrient\\Protocols\\Binary\\Data\\Record')) {
                             array_push($embeddedData, $this->extractRecord($childRec));
                         } else {
                             // LINKSET, LINKLIST, LINKMAP
                             if (is_a($childRec, 'PhpOrient\\Protocols\\Binary\\Data\\ID')) {
                                 $vortex = $this->findRelationByRid($childRec);
                                 if (!empty($vortex)) {
                                     array_push($embeddedData, $this->extractRecord($vortex));
                                 } else {
                                     // not loaded
                                     array_push($embeddedData, $childRec);
                                 }
                             }
                         }
                     }
                     $recordData[$key] = $embeddedData;
                 } else {
                     if ($key !== '@rid' && is_a($value, 'PhpOrient\\Protocols\\Binary\\Data\\ID')) {
                         $vortex = $this->findRelationByRid($value);
                         if (!empty($vortex)) {
                             $recordData[$key] = $this->extractRecord($vortex);
                         }
                         //??? convert to ActiveRecord
                     } else {
                         if (is_a($value, 'PhpOrient\\Protocols\\Binary\\Data\\Bag')) {
                             $rids = $value->getRids();
                             foreach ($rids as $rid) {
                                 $relation = $this->findRelationByRid($rid);
                                 if (empty($relation)) {
                                     continue;
                                 }
                                 // relation not loaded
                                 if ($this->isEdge($relation)) {
                                     //? it always edge
                                     $edgeData = $relation->getOData();
                                     $vortex = $this->findRelationByRid($edgeData['in']);
                                     $vortexData = $vortex->getOData();
                                     // convert DateTime to ISO
                                     foreach ($vortexData as $vkey => $vval) {
                                         if (is_a($vval, 'DateTime')) {
                                             $vortexData[$vkey] = $vval->format('Y-m-d H:i:s');
                                         }
                                     }
                                     $vortexData['@rid'] = $this->IDtoRid($vortex->getRid());
                                     $vortexData['@version'] = $vortex->getVersion();
                                     $vortexData['@class'] = $vortex->getOClass();
                                     $vortexData['_edge'] = $this->IDtoRid($relation->getRid());
                                     $recordData[$key] = $vortexData;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // continue;
         // if(    !is_a($value, 'PhpOrient\Protocols\Binary\Data\Bag')
         // // && !is_a($value, 'PhpOrient\Protocols\Binary\Data\ID')
         // ) {
         // continue;
         // }
     }
     return $recordData;
 }
Example #3
0
 /**
  * Hydrate a SpiderRecord from an OrientRecord
  *
  * @param $orientRecord
  * @return Response
  */
 protected function mapOrientRecordToCollection(OrientRecord $orientRecord)
 {
     // Or we map a single record to a Spider Record
     $collection = new Collection($orientRecord->getOData());
     $collection->add(['id' => $orientRecord->getRid()->jsonSerialize(), 'label' => $orientRecord->getOClass(), 'meta.rid' => $orientRecord->getRid(), 'meta.version' => $orientRecord->getVersion(), 'meta.oClass' => $orientRecord->getOClass()]);
     $collection->protect('id');
     $collection->protect('label');
     $collection->protect('meta');
     return $collection;
 }
Example #4
0
 /**
  * Update a Record
  *
  * @param Record $record
  *
  * @return RecordUpdate|Record
  */
 public function recordUpdate(Record $record)
 {
     return $this->getTransport()->execute('recordUpdate', ['rid' => $record->getRid(), 'record' => $record, 'record_version' => $record->getVersion()]);
 }