Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDO: Support for PDO::ERRMODE_EXCEPTION (PHP8) #394

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

dakujem
Copy link
Contributor

@dakujem dakujem commented Jun 22, 2021

  • 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 dakujem changed the title PDO: Support for PDO::ERRMODE_EXCEPTION PDO: Support for PDO::ERRMODE_EXCEPTION (PHP8) Jun 22, 2021
@dg dg force-pushed the master branch 3 times, most recently from 45c0839 to 8881eb1 Compare November 29, 2021 12:49
@dg dg force-pushed the master branch 3 times, most recently from 80c861c to 26f2657 Compare December 6, 2021 18:13
@dakujem dakujem force-pushed the feat/support-exception-errmode-php8 branch from fd45178 to e6baef8 Compare December 11, 2021 17:33
@dg
Copy link
Owner

dg commented Dec 12, 2021

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 dg force-pushed the master branch 4 times, most recently from 0efa5c1 to 0bdf956 Compare December 12, 2021 16:47
@dakujem
Copy link
Contributor Author

dakujem commented Dec 14, 2021

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

@dg dg force-pushed the master branch 6 times, most recently from 17866e0 to 82c45c3 Compare August 9, 2023 14:38
@dg dg force-pushed the master branch 2 times, most recently from dd46ea7 to 9e71132 Compare September 29, 2023 14:07
@dg
Copy link
Owner

dg commented Sep 29, 2023

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

@dakujem
Copy link
Contributor Author

dakujem commented Oct 2, 2023

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.

@dg
Copy link
Owner

dg commented Oct 2, 2023

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

@dakujem
Copy link
Contributor Author

dakujem commented Oct 3, 2023

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
Copy link
Contributor Author

dakujem commented Feb 14, 2025

I don't fully understand why this useful feature is still not integrated after 4 years.

Came across a note in my code that works around this shortcoming, just to see nothing has been done here nor in #393 ... now there is Dibi v5 already out which only runs on PHP 8 and that means in default settings this PDO driver will simply not work.

See here: https://www.php.net/manual/en/pdo.error-handling.php
image

Because of the private-access props in the driver, there is no way to just tweak the piece of code in the constructor, so one needs to copy the whole driver. 🤦‍♂️

Seems like releasing a separate package with just the improved PDO driver is the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants