Compare commits

...

2 Commits

View File

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