Re: Return codes on PDO insert
| From: | Paul M Foster | Date: | Fri, 26 Mar 2021 00:49:15 +0000 |
| Subject: | Re: Return codes on PDO insert | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-327527@lists.php.net to get a copy of this message | ||
On Thu, Mar 25, 2021 at 02:18:15PM -0700, R. Eric Wheeler wrote:
> Paul,
>
> I think what you are looking for is
> https://www.php.net/manual/en/pdo.setattribute.php
>
> Specifically PDO::ATTR_ERRMODE.
>
> Or are you saying that PDO::errorCode() had no errors?
The attribute you mention only specified how an error gets "advertised",
not whether an error is thrown. At its lowest setting, it still sets error
codes.
In the case where an insert fails because of a constraint violation,
PDO::errorInfo()[0] produces a SQLSTATE error code of 000, meaning no
error. Yet it seems like a failed insert should produce some kind of code.
I'm wondering if I'm wrong about that or if I'm doing something wrong.
Paul
--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com