php.net |  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
Votes:3
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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joe at digg dot com
New email:
PHP Version: OS:

 

 [2008-03-03 21:46 UTC] joe at digg dot com
Description:
------------
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. 


Patches

Pull Requests

History

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] jani@php.net
-Package: Feature/Change Request +Package: PDO related
 [2017-04-24 19:12 UTC] adambaratz@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: adambaratz
 [2017-04-24 19:12 UTC] adambaratz@php.net
This feature will be released with PHP 7.2 for emulated prepared statements:
https://wiki.php.net/rfc/debugging_pdo_prepared_statement_emulation_v2

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: Thu Nov 21 18:01:29 2024 UTC