From 67df205ea8fddb94cacd07b83e34e296b573bc26 Mon Sep 17 00:00:00 2001 From: guilhermeblanco Date: Wed, 31 Mar 2010 20:50:14 +0000 Subject: [PATCH] [2.0][DDC-274] Moved Sql to SQL loggers. Also implemented some todos. --- lib/Doctrine/DBAL/Logging/EchoSQLLogger.php | 49 +++++++++++++++++++++ lib/Doctrine/DBAL/Logging/SQLLogger.php | 45 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 lib/Doctrine/DBAL/Logging/EchoSQLLogger.php create mode 100644 lib/Doctrine/DBAL/Logging/SQLLogger.php diff --git a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php new file mode 100644 index 000000000..9541547d9 --- /dev/null +++ b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php @@ -0,0 +1,49 @@ +. + */ + +namespace Doctrine\DBAL\Logging; + +/** + * A SQL logger that logs to the standard output using echo/var_dump. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @version $Revision$ + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +class EchoSQLLogger implements SQLLogger +{ + /** + * {@inheritdoc} + */ + public function logSQL($sql, array $params = null) + { + echo $sql . PHP_EOL; + + if ($params) { + var_dump($params); + } + } +} \ No newline at end of file diff --git a/lib/Doctrine/DBAL/Logging/SQLLogger.php b/lib/Doctrine/DBAL/Logging/SQLLogger.php new file mode 100644 index 000000000..a8b01a3bd --- /dev/null +++ b/lib/Doctrine/DBAL/Logging/SQLLogger.php @@ -0,0 +1,45 @@ +. + */ + +namespace Doctrine\DBAL\Logging; + +/** + * Interface for SQL loggers. + * + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @link www.doctrine-project.org + * @since 2.0 + * @version $Revision$ + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + */ +interface SQLLogger +{ + /** + * Logs a SQL statement somewhere. + * + * @param string $sql The SQL to be executed. + * @param array $params The SQL parameters. + */ + function logSQL($sql, array $params = null); +} \ No newline at end of file