diff --git a/application/Bootstrap.php b/application/Bootstrap.php index b33334a4..2c2d91ce 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -146,7 +146,14 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap protected function _initDoctrine() { $c = new Zend_Config($this->getOptions()); + $config = new \Doctrine\DBAL\Configuration(); + + if (APPLICATION_ENV == 'development') { + $logger = new Scores_Logger_Sql(); + $config->setSQLLogger($logger); + } + $connectionParams = array( 'dbname' => $c->profil->db->metier->params->dbname, 'user' => $c->profil->db->metier->params->username, diff --git a/library/Scores/Logger/Sql.php b/library/Scores/Logger/Sql.php new file mode 100644 index 00000000..4fd81f9f --- /dev/null +++ b/library/Scores/Logger/Sql.php @@ -0,0 +1,46 @@ +enabled) { + $this->start = microtime(true); + $this->query = array('sql' => $sql, 'params' => $params, 'types' => $types, 'executionMS' => 0); + } + } + + /** + * {@inheritdoc} + */ + public function stopQuery() + { + if ($this->enabled) { + $this->query['executionMS'] = microtime(true) - $this->start; + file_put_contents('logger.log', print_r($this->query,1), FILE_APPEND); + } + } +} \ No newline at end of file