Re: PDO SQLite: statement attributes for SQL text retrieval
| From: | Juris Evertovskis | Date: | Fri, 03 Apr 2026 17:33:14 +0000 |
| Subject: | Re: PDO SQLite: statement attributes for SQL text retrieval | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130554@lists.php.net to get a copy of this message | ||
On 2026-04-03 15:29, Ilia wrote:
Hi internals, I'm looking for feedback on a small pdo_sqlite addition. PR: https://github.com/php/php-src/pull/21456 Implements: https://github.com/php/php-src/issues/21322 Two new read-only statement attributes on Pdo\Sqlite: - Pdo\Sqlite::ATTR_SQL -- original SQL text of a prepared statement (via sqlite3_sql()) - Pdo\Sqlite::ATTR_EXPANDED_SQL -- SQL with bound parameters inlined (via sqlite3_expanded_sql()) $stmt = $db->prepare('SELECT :name AS greeting'); $stmt->bindValue(':name', 'hello'); $stmt->execute();Hello, I don't doubt the need to extract statement strings since logging the executed statements is something I do often, especially during development (tools like laravel-debugbar and newrelic's achieve that). It helps noticing repeated queries and other issues. But two things here are unclear to me: - What's insufficient with$stmt->getAttribute(Pdo\Sqlite::ATTR_SQL); // "SELECT :name AS greeting" $stmt->getAttribute(Pdo\Sqlite::ATTR_EXPANDED_SQL); // "SELECT 'hello' AS greeting"This mirrors SQLite3Stmt::getSQL() from the non-PDO API, but uses PDO's getAttribute() mechanism rather than adding a driver-specific method. The attribute system is how PDO drivers expose driver-specific functionality, so it's a natural fit. ATTR_EXPANDED_SQL is gated behind a configure check for sqlite3_expanded_sql availability. I don't think this needs a full RFC given the scope (two read-only attributes, single driver, no BC impact), but I wanted input from the list. Thoughts? -- Ilia Alshanetsky Technologist, CTO, Entrepreneur E: ilia@ilia.ws T: @iliaa B: http://ilia.ws
->queryString and other existing features? Does one of these overlap with ->queryString or not?
- What's so special about SQLite? Wouldn't the same need be just as present for any other driver?
BR,
Juris