extend whatever datasource you're using and override the _execute
method to log and pass back to the parent.
For example, let's assume you're currently using dbo_mysql. That means
your db config is something like this:

class DATABASE_CONFIG {

        var $default = array(
                'driver' => 'mysql',
                // ...
        )
}

so change 'driver' to 'mysql_with_log', and create the file app/model/
datasources/dbo/mysql_with_log.php :

<?php

require (LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS .
'dbo_mysql.php');

class DboMysqlWithLog extends DboMysql {
  function _execute($sql) {
    $this->log($sql);
    return parent::_execute($sql);
  }
}

?>

For a different dbo, just replace the appropriate name.

On Nov 7, 11:22 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi bakers.
>
> I need to log every SQL command executed by models. I was using the
> datasource's queriesLog variable to do this but when i put my server
> in production mode queries stoped being logged. I looked at the code
> and saw that SQL queries where only being logged in debug mode!
>
> I _really_ need to log SQL commands (insert, update and delete).
> Before i go and hack away at the core i would like to know if there is
> an easy way of doing this?
>
> Thanks in advance.
>
> Gonçalo Marrafa.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to