diff --git a/src/engine/Model.php b/src/engine/Model.php index 860f608..800b182 100644 --- a/src/engine/Model.php +++ b/src/engine/Model.php @@ -92,11 +92,6 @@ abstract class Model $model_upd[$field->getModelName()] = $value; break; - case ModelFieldType::BITFIELD: - $db_upd[$name] = $value; - $model_upd[$field->getModelName()] = $value; - break; - default: $value = (string)$value; $db_upd[$name] = $value; @@ -179,9 +174,6 @@ abstract class Model case 'bool': $mytype = ModelFieldType::BOOLEAN; break; - case 'mysql_bitfield': - $mytype = ModelFieldType::BITFIELD; - break; default: if (enum_exists($typename)) { $mytype = ModelFieldType::BACKED_ENUM; diff --git a/src/engine/ModelFieldType.php b/src/engine/ModelFieldType.php index a46770a..706ab8c 100644 --- a/src/engine/ModelFieldType.php +++ b/src/engine/ModelFieldType.php @@ -11,6 +11,5 @@ enum ModelFieldType case BOOLEAN; case JSON; case SERIALIZED; - case BITFIELD; case BACKED_ENUM; } \ No newline at end of file diff --git a/src/engine/ModelProperty.php b/src/engine/ModelProperty.php index 6ff731b..79995fe 100644 --- a/src/engine/ModelProperty.php +++ b/src/engine/ModelProperty.php @@ -57,9 +57,6 @@ class ModelProperty $val = null; return $val; - case ModelFieldType::BITFIELD: - return new MySQLBitField($value); - case ModelFieldType::BACKED_ENUM: try { return $this->realType::from($value); diff --git a/src/engine/MySQLBitField.php b/src/engine/MySQLBitField.php deleted file mode 100644 index f4b6b9b..0000000 --- a/src/engine/MySQLBitField.php +++ /dev/null @@ -1,65 +0,0 @@ -value = gmp_init($value); - $this->size = $size; - } - - /** - * @throws Exception - */ - public function has(int $bit): bool { - $this->validateBit($bit); - return gmp_testbit($this->value, $bit); - } - - /** - * @throws Exception - */ - public function set(int $bit): void { - $this->validateBit($bit); - gmp_setbit($this->value, $bit); - } - - /** - * @throws Exception - */ - public function clear(int $bit): void { - $this->validateBit($bit); - gmp_clrbit($this->value, $bit); - } - - public function isEmpty(): bool { - return !gmp_cmp($this->value, 0); - } - - public function __toString(): string { - $buf = ''; - for ($bit = $this->size - 1; $bit >= 0; --$bit) - $buf .= gmp_testbit($this->value, $bit) ? '1' : '0'; - if (($pos = strpos($buf, '1')) !== false) { - $buf = substr($buf, $pos); - } else { - $buf = '0'; - } - return $buf; - } - - /** - * @throws Exception - */ - private function validateBit(int $bit): void { - if ($bit < 0 || $bit >= $this->size) - throw new Exception('invalid bit ' . $bit . ', allowed range: [0..' . $this->size . ')'); - } -} \ No newline at end of file