Skip to content

Commit 2e5391b

Browse files
committed
InsertOrUpdate does not change the primary key on update
1 parent e1256bc commit 2e5391b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/PHPFUI/ORM/Record.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,11 @@ private function privateInsert(bool $updateOnDuplicate, string $ignore = '') : i
924924

925925
if (static::$autoIncrement && $returnValue)
926926
{
927-
$this->current[static::$primaryKeys[0]] = $returnValue = (int)\PHPFUI\ORM::lastInsertId(static::$primaryKeys[0]);
927+
$returnValue = (int)\PHPFUI\ORM::lastInsertId(static::$primaryKeys[0]);
928+
if ($returnValue)
929+
{
930+
$this->current[static::$primaryKeys[0]] = $returnValue;
931+
}
928932
}
929933

930934
$this->loaded = true; // record is effectively read from the database now

0 commit comments

Comments
 (0)