Using PHP PDO MySQL, exception mode.
Does a PDOException code for [MySQL] deadlocks exist?
Is there an alternative if it doesn\'t?
I encountered a situation where the above example was not enough as the \PDOException was caught and thrown again with an other message. I had to catch \Throwable and check all the $exc->getPrevious() to see if it was instaceof \PDOException. As a safety net if the error was not instance of \PDOException I checked the error message to see if it contains the phrase 'try restarting transaction'