I'm building an mobile app that connect to a server.
My SQL query insert data as email and password, with a UNIQUE constraint on email. It is called from my app with a post and return the PDO output (the trace of the exception if any).
I want to display the user if he enter an email already registered.
For now, I can think of 2 things :
$pdo_exception->getCode()
equals 23000
, which seems to be the code for UNIQUE duplicates keysThe first solution means another call to the database, which is not really wanted, and the second doesn't seem to be made for this, since I didn't find anything on the web.
What is the actual best way ?
(the same question could go for any other exception)