mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 10:02:02 -04:00
Check actual error code for duplicate row inserted in newsletter subscriptions
This commit is contained in:
parent
69df5ac43a
commit
f7558eab3a
1 changed files with 4 additions and 1 deletions
|
@ -31,10 +31,13 @@ class NewsletterSubscriber extends PropertiesBase{
|
||||||
Db::Query('insert into NewsletterSubscribers (Email, Uuid, FirstName, LastName, IsConfirmed, IsSubscribedToNewsletter, IsSubscribedToSummary, Timestamp) values (?, ?, ?, ?, ?, ?, ?, utc_timestamp());', [$this->Email, $this->Uuid, $this->FirstName, $this->LastName, false, $this->IsSubscribedToNewsletter, $this->IsSubscribedToSummary]);
|
Db::Query('insert into NewsletterSubscribers (Email, Uuid, FirstName, LastName, IsConfirmed, IsSubscribedToNewsletter, IsSubscribedToSummary, Timestamp) values (?, ?, ?, ?, ?, ?, ?, utc_timestamp());', [$this->Email, $this->Uuid, $this->FirstName, $this->LastName, false, $this->IsSubscribedToNewsletter, $this->IsSubscribedToSummary]);
|
||||||
}
|
}
|
||||||
catch(PDOException $ex){
|
catch(PDOException $ex){
|
||||||
if($ex->getCode() == '23000'){
|
if($ex->errorInfo[1] == 1062){
|
||||||
// Duplicate unique key; email already in use
|
// Duplicate unique key; email already in use
|
||||||
throw new Exceptions\NewsletterSubscriberExistsException();
|
throw new Exceptions\NewsletterSubscriberExistsException();
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
throw $ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->NewsletterSubscriberId = Db::GetLastInsertedId();
|
$this->NewsletterSubscriberId = Db::GetLastInsertedId();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue