Php 有没有办法记录SQLite查询?
我使用的是事先准备好的陈述,如:Php 有没有办法记录SQLite查询?,php,sqlite,Php,Sqlite,我使用的是事先准备好的陈述,如: $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->b
$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();
当使用准备好的语句时,有没有办法记录查询
编辑:如果无法从SQLite3 prepared语句中提取查询,您建议采用什么策略来调试查询?您可以通过重写
prepare
方法来扩展SQLite3
类并包装SQLite3Stmt
对象。在包装器中实现bindValue
和execute
方法,并在SQLite3Stmt
对象上调用它们(在此处添加日志记录)。要完成它,您可以为任何未拦截的方法/属性添加\uu get
和\uu call
函数
要实现这一点,您必须将“new SQLite3”更改为“new SQLite3Debug”(假设您的扩展类被称为new SQLite3Debug)。如果您试图用数据记录语句,我想您会失望的。Brad是对的-文档显示preparedstatement上没有将最终查询返回log的方法。Brad,msgmash.com:对于调试/记录查询,您会建议什么替代策略?@GaminGrounds:您共享的链接讨论了c/c++语言中的错误记录,而我正在用PHP寻找解决方案,我在发布问题之前进行了搜索:-)