|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-02-01 17:34 UTC] adambaratz@php.net
-Summary: PDOException Improvements
+Summary: add fields to PDOException
-PHP Version: 7.1.1
+PHP Version: Irrelevant
[2017-02-01 17:34 UTC] adambaratz@php.net
[2017-02-04 23:00 UTC] wowkise at gmail dot com
[2017-10-24 08:32 UTC] kalle@php.net
-Package: PDO Core
+Package: PDO related
[2021-08-04 15:00 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2021-08-04 15:00 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 08:00:02 2025 UTC |
Description: ------------ I would like the possibility of improving PDOException to include the query string and bind parameters if available, for example. $sql = 'select foo from bar fail'; $bind = []; $pdo = 'pdo instance'; $pdo->query($sql,$bind); set_exception_handler( function ( \PDOException $e) { var_dump( $e->queryString, $e->queryBind); } ); now you might ask why i would need such thing, i personally use set_exception_handler to handle all logging in production and we sometimes have case of failed queries, and to produce good reports we need access to the queryString and the bind data if available, and i was planing on making generic class for handling all these cases. but it's impossible to get the pdo instance if the class is generic, what i've done so far is to have a generic class that run on top of pdo and catch the PDOException and wrap them in another instance of Exception that extends PDOEXception that has special methods such (getQuery() and getBind() ), while this works if i can control the whole app, it's become really hard to release something to the public that works out of the box with PDO, without having to wrap all those class.