I am using prepared statements like:
$mysqlite = new SQLite3("test.sqlite", SQLITE3_OPEN_READWRITE);
$stmnt = $mysqlite->prepare("INSERT INTO Friends VALUES(?,?,?)");
$stmnt->bindValue(1,4,SQLITE3_INTEGER);
$stmnt->bindValue(2,"Jane",SQLITE3_TEXT);
$stmnt->bindValue(3,"F",SQLITE3_TEXT);
$stmnt->execute();
Is there a way to log queries when using prepared statements?
Edit:
What strategy would you suggest to debug queries, in case queries cannot be extracted from SQLite3 prepared statement?
You could extend
SQLite3class and wrap theSQLite3Stmtobject by overriding thepreparemethod. In your wrapper implement thebindValueandexecutemethods and call them on theSQLite3Stmtobject (add logging here). To finish it off you could add the magic__getand__callfunctions for any methods/properties you’re not intercepting.For this to work you have to change “new SQLite3” to “new SQLite3Debug” (assuming your extended class is called this).