dibi icon indicating copy to clipboard operation
dibi copied to clipboard

PDO: Support for PDO::ERRMODE_EXCEPTION (PHP8)

Open dakujem opened this issue 4 years ago • 9 comments

  • new feature, no existing code will break (full bc)

I added support for PDO in PDO::ERRMODE_EXCEPTION error mode using a single try-catch block.

👉 Since in PHP 8 PDO::ERRMODE_EXCEPTION is the default error mode!

dakujem avatar Jun 22 '21 21:06 dakujem

I think it would be best to do a BC break and add support (only) for PDO::ERRMODE_EXCEPTION in dibi 5.0 and keep version 4.2 as it is. What do you think?

dg avatar Dec 12 '21 03:12 dg

Since it is backwards compatible, I see no reason not to include it in v4. It can be the default in v5.

dakujem avatar Dec 14 '21 13:12 dakujem

👉 PR #393 is open for v4 branch.

dakujem avatar Dec 14 '21 13:12 dakujem

bump.

dakujem avatar Aug 02 '23 12:08 dakujem

I think it's a more complicated matter, see #293

dg avatar Sep 29 '23 14:09 dg

I don't see how that's related. I do not need dibi to create me an exception. All I want is to run PDO connection in exception mode.

This PR is 100% backward compatible with existing code and does not cause any breaks. It only allows PDO users to enable connection mode that throws exceptions on errors (which is what Dibi essentially does for other connection types).

Without this, users are not even allowed to connect using EXCEPTION mode.

What #293 is trying to solve is broken WARNING mode handling. That's not the concern of this PR.

dakujem avatar Oct 02 '23 12:10 dakujem

But exceptions also throw all other PDO methods, not just query.

dg avatar Oct 02 '23 15:10 dg

And the problem is that they would not be caught by Dibi? I think users would be better off with native PDO exceptions than not being able to use the exception mode.

dakujem avatar Oct 03 '23 17:10 dakujem