PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

MySQLnd Plugins: Writing a MySQL Query Logger in PHP

Note: This article was originally published at Planet PHP on 16 August 2010.
Planet PHP

During the development of an application, not all time is spent on writing code. A lot of time is spent on reading debug output, crawling through log files and firing up the debugger to figure out what the application does. While the debugger helps us to inspect details of a running application on a testing environment, logfiles are often the only indication of the origin of an error on a production system. In this blogpost I want to describe how to log SQL statements on an existing application without touching any existing line of code at all. We will use a new MySQLnd Extension developed at the Mayflower OpenSource Labs for that purpose.

As an example, I will use PHProjekt 6. The project is particularly suitable for demonstration purposes as it has a logging infrastructure for function calls, but does not log SQL statements.


Continue reading "MySQLnd Plugins: Writing a MySQL Query Logger in PHP"