Re: Return codes on PDO insert

[email protected] (Paul M Foster)
Newsgroups php.general
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.