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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user