From 54ca43c62beaf991785fe0131c5816e446832eba Mon Sep 17 00:00:00 2001 From: avl Date: Fri, 29 Aug 2008 04:42:47 +0200 Subject: [PATCH] SQL Profiler --- ipf/orm/connection/profiler.php | 89 +++++++++++++++++++++++++++++++++ ipf/orm/exception/profiler.php | 3 ++ 2 files changed, 92 insertions(+) create mode 100644 ipf/orm/connection/profiler.php create mode 100644 ipf/orm/exception/profiler.php diff --git a/ipf/orm/connection/profiler.php b/ipf/orm/connection/profiler.php new file mode 100644 index 0000000..3c0a340 --- /dev/null +++ b/ipf/orm/connection/profiler.php @@ -0,0 +1,89 @@ +start(); + + if ( ! in_array($a[0], $this->events, true)) { + $this->events[] = $a[0]; + } + } else { + // after-event listener found + $a[0]->end(); + } + /** + * If filtering by query type is enabled, only keep the query if + * it was one of the allowed types. + */ + /* + if ( !is_null($this->filterTypes)) { + if ( ! ($a[0]->getQueryType() & $this->_filterTypes)) { + + } + } + */ + } + + public function get($key) + { + if (isset($this->events[$key])) { + return $this->events[$key]; + } + return null; + } + + public function getAll() + { + return $this->events; + } + + public function getIterator() + { + return new ArrayIterator($this->events); + } + + public function count() + { + return count($this->events); + } + + public function pop() + { + return array_pop($this->events); + } + + public function lastEvent() + { + if (empty($this->events)) { + return false; + } + + end($this->events); + return current($this->events); + } +} \ No newline at end of file diff --git a/ipf/orm/exception/profiler.php b/ipf/orm/exception/profiler.php new file mode 100644 index 0000000..5fa9ad5 --- /dev/null +++ b/ipf/orm/exception/profiler.php @@ -0,0 +1,3 @@ +