Is there a way to log SQLite queries?

I use prepared expressions, for example:

$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 register requests when using prepared statements?

Edit:
What strategy do you suggest debugging queries if queries cannot be extracted from a prepared SQLite3 statement?

+4
source share
1 answer

You can extend the SQLite3 class and wrap the SQLite3Stmt object by overriding the prepare method. In your shell, implement the bindValue and execute methods and call them in the SQLite3Stmt object (add registration here). To complete it, you can add magic __get and __call functions for any methods / properties that you do not intercept.

To do this, you need to change the "new SQLite3" to the "new SQLite3Debug" (assuming your extended class is called this).

+3
source

Source: https://habr.com/ru/post/1400519/


All Articles