It might be better to enable the query profiler, which captures all queries. Then, in a late-running dispatchShutdown() front controller plugin, you can loop through the queries from the profiler to log all of the inserts/updates/deletes. This wouldn't require any changes to your models and would work even if you are querying the DB directly ($dbAdapter->query(/* sql */))
-- Hector On Fri, Oct 23, 2009 at 3:47 PM, David Zapata <[email protected]>wrote: > > Good day. > > I'm having a problem with some models usign Zend Framework. The models we > have extend from Zend_Db_Table. The most of the methods are using Zend_Logs > inside to track the executed queries and other data (in development > environment). Some of the queries, I mean, the insert, delete or update > queries, are executed using $this->_db->query( $str_sql ) where $str_sql is > a string (made by hand, not using Zend objects) containing the SQL code. > > I've been asked to implement a Zend_Log object with a Zend_Log_Writer_Db to > log only the SQL queries that edit data (used manually before every > $this->_db->query( $str_sql ) execution). > > Of course, I know this is not the right way to use Zend_Models, but I must > find a way to replace the Zend_Log_Writer_Db, and use instead another > query() execution that inserts only a log in a database table if the query > in execution is a Insert, update or delete... This must be done automaticly > by the Model class. > > I've searched in google a lot about overwriting the query() method, or > creating a helper class that I can use to extend it in our model classes, > but I can't find a may... > > Please, show me some light about this... > -- > View this message in context: > http://www.nabble.com/Log-only-insert%2C-update-or-delete-queries-tp26034303p26034303.html > Sent from the Zend Framework mailing list archive at Nabble.com. > >
