Compare commits

..

3 Commits

View File

@@ -31,7 +31,7 @@ class Model
/**
* @var array Attributes to ignore when saving to the database.
*/
protected static array $dbIgnoreSave = ['id'];
protected static array $dbIgnoreSave = [];
/**
* @var array Attributes that should be explicitly saved, even if private/protected.
@@ -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";
}
$set[] = "$key=:$key";
static::$dbQueryVariables[':' . $key] = $value;
}
$table = static::table();
@@ -511,11 +507,9 @@ class Model
static::$dbQueryVariables = [];
foreach ($atts as $key => $value) {
if (isset($value)) {
$into[] = "$key";
$values[] = ":$key";
static::$dbQueryVariables[":$key"] = $value;
}
$into[] = "$key";
$values[] = ":$key";
static::$dbQueryVariables[":$key"] = $value;
}
$table = static::table();
@@ -523,7 +517,7 @@ class Model
static::query($sql);
$pk = static::$dbPrimaryKey;
$this->$pk = $db->lastInsertId();
$this->$pk ??= $db->lastInsertId();
$this->markAsSaved();
}