From 1bdd4ba7ca8f4b7672c89b4e4b86927281873164 Mon Sep 17 00:00:00 2001 From: chtito Date: Sat, 27 Jan 2007 12:40:51 +0000 Subject: [PATCH] allowing to log the parameters of prepared queries --- lib/Doctrine/Db/Event.php | 19 +++++++++++++++++-- lib/Doctrine/Db/Statement.php | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/Db/Event.php b/lib/Doctrine/Db/Event.php index cb8680b19..175658a53 100644 --- a/lib/Doctrine/Db/Event.php +++ b/lib/Doctrine/Db/Event.php @@ -50,6 +50,10 @@ class Doctrine_Db_Event * @var string $query the sql query associated with this event (if any) */ protected $query; + /** + * @var string $params the parameters associated with the query (if any) + */ + protected $params; /** * @see Doctrine_Db_Event constants * @var integer $code the event code @@ -70,11 +74,12 @@ class Doctrine_Db_Event * @param integer $code the event code * @param string $query the sql query associated with this event (if any) */ - public function __construct($invoker, $code, $query = null) + public function __construct($invoker, $code, $query = null, $params = array()) { $this->invoker = $invoker; $this->code = $code; - $this->query = $query; + $this->query = $query; + $this->params = $params; } /** * getQuery @@ -161,6 +166,16 @@ class Doctrine_Db_Event { return $this->invoker; } + /** + * getParams + * returns the parameters of the query + * + * @return array parameters of the query + */ + public function getParams() + { + return $this->params; + } /** * Get the elapsed time (in microseconds) that the event ran. If the event has * not yet ended, return false. diff --git a/lib/Doctrine/Db/Statement.php b/lib/Doctrine/Db/Statement.php index 7be13f908..edd6f867b 100644 --- a/lib/Doctrine/Db/Statement.php +++ b/lib/Doctrine/Db/Statement.php @@ -67,7 +67,7 @@ class Doctrine_Db_Statement extends PDOStatement public function execute(array $params = null) { - $event = new Doctrine_Db_Event($this, Doctrine_Db_Event::EXECUTE, $this->queryString); + $event = new Doctrine_Db_Event($this, Doctrine_Db_Event::EXECUTE, $this->queryString, $params); $this->dbh->getListener()->onPreExecute($event);