This method returns the error code of an error in a
five-character format, in the SQLSTATE format. It
doesn’t seem to be supported in MySQL yet, so it returns either an
empty value or, for a general error, S1000. Here is
an example:
$state = $dbh->state();
print "SQLSTATE: $state";