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

@ -95,7 +95,7 @@ class Payment{
}
try{
Db::Query('
$this->PaymentId = Db::QueryInt('
INSERT into Payments (UserId, Created, Processor, TransactionId, Amount, Fee, IsRecurring, IsMatchingDonation)
values(?,
?,
@ -105,12 +105,11 @@ class Payment{
?,
?,
?)
returning PaymentId
', [$this->UserId, $this->Created, $this->Processor, $this->TransactionId, $this->Amount, $this->Fee, $this->IsRecurring, $this->IsMatchingDonation]);
}
catch(Exceptions\DuplicateDatabaseKeyException){
throw new Exceptions\PaymentExistsException();
}
$this->PaymentId = Db::GetLastInsertedId();
}
}