You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PDO\SQLite: Add support for getting raw SQL query (same as SQLite3::getSQL) #21322
What is a potential use case for this? SQL string is an input to the prepared statement so it's already something that the user knows. Why would they need to be able to fetch it back from the PDO?
It's useful in case an error happens, you don't want to have to keep in memory every SQL query just in case an error might happen later on, even if the error is not related to the SQL query.
Also having the expanded query is nice for debug :)
Can you explain a bit more and maybe show an example? What do you mean by "keep in memory every SQL query"? It's only one query that will be executed.
It's pretty rare that an error happens due to the data, so while an expanded query is useful for debugging, it has a very limited usefulness. Most of the time, when an error happens, you need to know the file and line number, and in the stacktrace you can also see the parameters passed, so that should already cover most of the debugging scenarios.
Activity
ext/pdo_sqlite: add ATTR_SQL and ATTR_EXPANDED_SQL statement attributes
kamil-tekiela commentedon Apr 3, 2026
What is a potential use case for this? SQL string is an input to the prepared statement so it's already something that the user knows. Why would they need to be able to fetch it back from the PDO?
bohwaz commentedon Apr 3, 2026
It's useful in case an error happens, you don't want to have to keep in memory every SQL query just in case an error might happen later on, even if the error is not related to the SQL query.
Also having the expanded query is nice for debug :)
kamil-tekiela commentedon Apr 3, 2026
Can you explain a bit more and maybe show an example? What do you mean by "keep in memory every SQL query"? It's only one query that will be executed.
It's pretty rare that an error happens due to the data, so while an expanded query is useful for debugging, it has a very limited usefulness. Most of the time, when an error happens, you need to know the file and line number, and in the stacktrace you can also see the parameters passed, so that should already cover most of the debugging scenarios.
bohwaz commentedon Apr 3, 2026
Only one query? There might thousands of queries in the same page.
The stack trace might not have the parameters, it depends how you do stuff.
This is useful, it is already present in SQLite3, it is useful to have in PDO\SQlite as well to have the same features in both classes.
MrSuddenJoy commentedon Apr 20, 2026
@kamil-tekiela Im with @bohwaz on this one; what (s)he requests is indeed quite useful and Im able to see real-life use case(s) of this.