Is there a simple way to log to queries to a file? I have Firebug profiling working no problem with:
resources.db.params.profiler.enabled = "true"
resources.db.params.profiler.class = "Zend_Db_Profiler_Firebug"
It would be nice to log this to a file with out writing a bunch of code.
Is there a class I can swap out with Zend_Db_Profiler_Firebug?
UPDATE: See my answer below.
As of ZF 1.11.11 there is no built in profiler class that will log queries to a file. Currently, FireBug is the only specialized Db Profiler.
Here are two ways in which you can solve it without loads of extra code though.
First, check out this answer as it shows how to extend
Zend_Db_Profilerto have it log the queries to a file onqueryEnd. If it doesn’t quite do what you want, you can extendZend_Db_Profilerand use the provided code as a starting point.This next example is a slight modification of a plugin I have in some of my applications that I use to profile queries when the application is in development. This method utilizes a
dispatchLoopShutdown()plugin to get an instance of the Db Profiler and log the queries to a file.To activate this plugin, you can use code like this in your bootstrap:
Ideally, in the long term, you would probably want to make a class that extends
Zend_Db_Profilerand allow additional options to be specified in your config such as the log file path, the log priority. This way you can leverage the existing filters toZend_Db_Profiler.