Add float type support and SQL handling for float values in object properties

- Included `float` as a valid type in type validation.
- Added SQL update logic for handling float values in object properties.
This commit is contained in:
Jeppe Bundgaard
2025-08-27 08:40:24 +02:00
parent 455cd14f22
commit c95116f2c9
@@ -51,7 +51,7 @@ class object_property
throw new \InvalidArgumentException("Table or column cannot be empty");
}
// Check if the type is valid
if (!in_array($this->type, ['int', 'varchar', 'text', 'date', 'datetime', 'string', 'timestamp', 'boolean', 'bool'])) {
if (!in_array($this->type, ['int', 'varchar', 'text', 'date', 'datetime', 'string', 'timestamp', 'boolean', 'bool', 'float'])) {
throw new \InvalidArgumentException("Invalid type: $this->type");
}
$sql = "SELECT $this->column FROM $this->table WHERE id = $this->id";
@@ -84,6 +84,9 @@ class object_property
} // If the value is an integer, set it to the integer value
elseif (is_int($value)) {
$sql = "UPDATE $this->table SET $this->column = $value WHERE id = $this->id";
} // If the value is a float, set it to the float value
elseif (is_float($value)) {
$sql = "UPDATE $this->table SET $this->column = $value WHERE id = $this->id";
} // If the value is a string, escape it
else {
$value = $db->escape_string($value);