/** * Get a binary representation of the query, ready to send to orient. * * @return string A binary serialized version of the query class. */ public function binarySerialize() { $bytes = Binary::packString($this->getOrientClass()); $bytes .= Binary::packString($this->language); $bytes .= Binary::packString($this->text); if (count($this->params)) { $bytes .= Binary::packString($this->serializeParams()); } else { $bytes .= Binary::packInt(0); } $bytes .= Binary::packByte(0); return $bytes; }
/** * (PHP 5 >= 5.0.0)<br/> * Offset to retrieve * @link http://php.net/manual/en/arrayaccess.offsetget.php * * @param mixed $offset <p> * The offset to retrieve. * </p> * * @todo add support for Tree Based RidBags * @return ID The RecordID instance at the given offset. */ public function offsetGet($offset) { if (isset($this->items[$offset])) { return $this->items[$offset]; } if ($this->type === self::EMBEDDED) { $start = $this->baseOffset + $offset * 10; $cluster = Binary::unpackShort(substr($this->deserialized, $start, 2)); $position = Binary::unpackLong(substr($this->deserialized, $start, 8)); $this->items[$offset] = new ID($cluster, $position); } else { $this->items[$offset] = false; } return $this->items[$offset]; }
/** * Write bytes to the socket. * * @param string $value */ protected function writeBytes($value) { $this->socket->write(Binary::packBytes($value)); }