Взгляните на $e->errorInfo
.
http://php.net/manual/en/class.pdoexception.php говорит:
errorInfo
- Соответствует PDO :: errorInfo () или PDOStatement :: errorInfo ()
http://php.net/manual/en/pdostatement.errorinfo.php документирует поля, возвращаемые errorInfo()
.
* * 1 022 Пример: * 1 023 *
try {
$stmt = $pdo->query("Bogus Query");
} catch (PDOException $e) {
echo "Caught exception!\n";
var_dump($e->errorInfo);
}
Выход:
Caught exception!
array(3) {
[0]=>
string(5) "42000"
[1]=>
int(1064)
[2]=>
string(157) "You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'Bogus Query' at line 1"
}
Вы можете видеть, что элемент [1]
является целым числом.