Use 'insert ... returning' instead of 'Db::GetLastInsertedId()'

This commit is contained in:
Alex Cabal 2025-03-10 11:04:20 -05:00
parent 4446b6d161
commit 5066252355
12 changed files with 44 additions and 57 deletions

View file

@ -251,20 +251,19 @@ class User{
}
try{
Db::Query('
$this->UserId = Db::QueryInt('
INSERT into Users (Email, Name, Uuid, Created, PasswordHash)
values (?,
?,
?,
?,
?)
returning UserId
', [$this->Email, $this->Name, $this->Uuid, $this->Created, $this->PasswordHash]);
}
catch(Exceptions\DuplicateDatabaseKeyException){
throw new Exceptions\UserExistsException();
}
$this->UserId = Db::GetLastInsertedId();
}
/**