fix(model): Remove the NULL check in the attribute loop

This commit is contained in:
kj
2026-06-19 15:27:18 -03:00
parent b95747bfe0
commit b13c07d3c4

View File

@@ -480,12 +480,8 @@ class Model
$set = []; $set = [];
foreach ($atts as $key => $value) { foreach ($atts as $key => $value) {
if ($value !== null) {
$set[] = "$key=:$key"; $set[] = "$key=:$key";
static::$dbQueryVariables[':' . $key] = $value; static::$dbQueryVariables[':' . $key] = $value;
} else {
$set[] = "$key=NULL";
}
} }
$table = static::table(); $table = static::table();
@@ -511,12 +507,10 @@ class Model
static::$dbQueryVariables = []; static::$dbQueryVariables = [];
foreach ($atts as $key => $value) { foreach ($atts as $key => $value) {
if (isset($value)) {
$into[] = "$key"; $into[] = "$key";
$values[] = ":$key"; $values[] = ":$key";
static::$dbQueryVariables[":$key"] = $value; static::$dbQueryVariables[":$key"] = $value;
} }
}
$table = static::table(); $table = static::table();
$sql = "INSERT INTO $table (" . join(', ', $into) . ") VALUES (" . join(', ', $values) . ")"; $sql = "INSERT INTO $table (" . join(', ', $into) . ") VALUES (" . join(', ', $values) . ")";