|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #44319 Add access to actual query sent to DB
Submitted: 2008-03-03 21:46 UTC Modified: 2017-04-24 19:12 UTC
Avg. Score:3.7 ± 1.9
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: joe at digg dot com Assigned: adambaratz (profile)
Status: Closed Package: PDO related
PHP Version: 5.2.5 OS: All
Private report: No CVE-ID: None
 [2008-03-03 21:46 UTC] joe at digg dot com
PEAR's DB (and others?) has a property called DB::$last_query that gives access to the *actual* query sent to the database. For the life of me I can't find this functionality in PDO and it's insanely useful for logging, debugging, etc. I doubt it'd be a big deal to add. 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-03 22:10 UTC] joe at digg dot com
I just looked through the code. Looks like what I'm asking for is access to stmt->active_query_string which is in PDOStatement::execute()'s code. I'll poke around a bit more. I'd like access to it whether the statement executes successfully or not so it makes sense to expose it via a member variable. 

I can probably come up with a patch, but would want to do it in a way that'd actually get accepted. Thoughts?
 [2011-04-08 21:27 UTC]
-Package: Feature/Change Request +Package: PDO related
 [2017-04-24 19:12 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: adambaratz
 [2017-04-24 19:12 UTC]
This feature will be released with PHP 7.2 for emulated prepared statements:

It's not possible for true prepared statements since there is no literal SQL executed.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 08:01:28 2024 UTC