serialize() public static méthode

Serialize a value.
public static serialize ( mixed $value, boolean $embedded = false ) : string
$value mixed The value to serialize.
$embedded boolean Whether this is a value embedded in another.
Résultat string The serialized value.
Exemple #1
0
 /**
  * Write the data to the socket.
  */
 protected function _write()
 {
     if ($this->_transport->getProtocolVersion() < 24) {
         $this->_writeInt($this->segment);
     }
     $this->_writeShort($this->cluster_id);
     $this->_writeBytes(CSV::serialize($this->record));
     // record type
     $this->_writeChar($this->record_type);
     $this->_writeByte($this->mode);
 }
Exemple #2
0
 /**
  * Write the data to the socket.
  */
 protected function _write()
 {
     if (!empty($this->rid) && $this->rid instanceof ID) {
         $this->cluster_id = $this->rid->cluster;
         $this->cluster_position = $this->rid->position;
     }
     $this->record->setRid(new ID($this->cluster_id, $this->cluster_position));
     $this->_writeShort($this->cluster_id);
     $this->_writeLong($this->cluster_position);
     if ($this->_transport->getProtocolVersion() >= 23) {
         $this->_writeBoolean($this->update_content);
     }
     $this->_writeBytes(CSV::serialize($this->record));
     $this->_writeInt($this->record_version_policy);
     $this->_writeChar($this->record_type);
     $this->_writeBoolean($this->mode);
 }
Exemple #3
0
 public function attach(Operation $operation)
 {
     if ($operation instanceof RecordUpdate) {
         $operationPayload = [['_writeByte', 1], ['_writeShort', $operation->cluster_id], ['_writeLong', (string) $operation->cluster_position], ['_writeChar', $operation->record_type], ['_writeInt', $operation->record_version], ['_writeString', CSV::serialize($operation->record)]];
         if ($this->_transport->getProtocolVersion() >= 23) {
             $operationPayload[] = ['_writeBoolean', $operation->update_content];
         }
         $this->_operation_stack[] = $operationPayload;
         $this->_pre_operation_records[$operation->cluster_position] = $operation;
     } elseif ($operation instanceof RecordDelete) {
         $this->_operation_stack[] = [['_writeByte', 2], ['_writeShort', $operation->cluster_id], ['_writeLong', (string) $operation->cluster_position], ['_writeChar', $operation->record_type], ['_writeInt', $operation->record_version]];
     } elseif ($operation instanceof RecordCreate) {
         $this->_operation_stack[] = [['_writeByte', 3], ['_writeShort', -1], ['_writeLong', (string) $this->_temp_cluster_position_seq], ['_writeChar', $operation->record_type], ['_writeString', CSV::serialize($operation->record)]];
         $this->_pre_operation_records[$this->_temp_cluster_position_seq] = $operation;
         $this->_temp_cluster_position_seq--;
     } else {
         throw new PhpOrientBadMethodCallException("Wrong command type " . get_class($operation));
     }
     return $this;
 }