Exemplo n.º 1
0
 /**
  * @param BinaryDataReader $packet
  * @param array $columnSchema
  * @throws ConfigException
  */
 private static function getFieldSpecial(BinaryDataReader $packet, array $columnSchema)
 {
     $metadata = ($packet->readUInt8() << 8) + $packet->readUInt8();
     $real_type = $metadata >> 8;
     if ($real_type === ConstFieldType::SET || $real_type === ConstFieldType::ENUM) {
         self::$field['type'] = $real_type;
         self::$field['size'] = $metadata & 0xff;
         self::getFieldSpecialValues($columnSchema);
     } else {
         self::$field['max_length'] = ($metadata >> 4 & 0x300 ^ 0x300) + ($metadata & 0xff);
     }
 }
 /**
  * @return int
  * @throws BinaryDataReaderException
  */
 private function readVariableInt()
 {
     $length = $this->binaryDataReader->getBinaryDataLength();
     $len = 0;
     for ($i = 0; $i < $length; $i++) {
         $size = $this->binaryDataReader->readUInt8();
         // Get the next 7 bits of the length.
         $len |= ($size & 127) << 7 * $i;
         if (($size & 128) === 0) {
             // This was the last byte. Return successfully.
             return $len;
         }
     }
     return $len;
 }