Req #74010 [NEW]: PDOException Improvements
| From: | wowkise at gmail dot com | Date: | Sat, 28 Jan 2017 15:59:00 +0000 |
| Subject: | Req #74010 [NEW]: PDOException Improvements | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-206991@lists.php.net to get a copy of this message | ||
From: wowkise at gmail dot com
Operating system:
PHP version: 7.1.1
Package: PDO Core
Bug Type: Feature/Change Request
Bug description:PDOException Improvements
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.
--
Edit bug report at https://bugs.php.net/bug.php?id=74010&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74010&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74010&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74010&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74010&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74010&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74010&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74010&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74010&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74010&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74010&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74010&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74010&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74010&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74010&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74010&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74010&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74010&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74010&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74010&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74010&r=mysqlcfg