From: Andrey Kutejko Date: Sat, 8 Jun 2013 16:35:08 +0000 (+0300) Subject: simplify SqlProfiler X-Git-Tag: 0.5~266 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=cd61acc4bc739176f974a933cd218a0b26c574b4;p=ipf.git simplify SqlProfiler --- diff --git a/ipf/orm/connection.php b/ipf/orm/connection.php index ce37457..0d161a0 100644 --- a/ipf/orm/connection.php +++ b/ipf/orm/connection.php @@ -853,7 +853,7 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta public function notifyDBListeners($method, $event) { foreach ($this->dbListeners as $listener) - if (method_exists($listener, $method)) + if (is_callable(array($listener, $method))) $listener->$method($event); } } diff --git a/ipf/orm/connection/profiler.php b/ipf/orm/connection/profiler.php index 6230025..4284fcb 100644 --- a/ipf/orm/connection/profiler.php +++ b/ipf/orm/connection/profiler.php @@ -1,6 +1,6 @@ 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/template/tag/sql.php b/ipf/template/tag/sql.php index 9251fce..4039581 100644 --- a/ipf/template/tag/sql.php +++ b/ipf/template/tag/sql.php @@ -5,10 +5,10 @@ class IPF_Template_Tag_Sql extends IPF_Template_Tag function start() { $profiler = IPF_Project::getInstance()->sqlProfiler; - if ($profiler!==null){ + if ($profiler !== null) { echo '

Sql Debug

set debug to false in settings project for disable sql profiler
'; $time = 0; - foreach ($profiler as $event) { + foreach ($profiler->events as $event) { $time += $event->getElapsedSecs(); $name = $event->getName(); if ($name=='fetch' || $name=='prepare' || $name=='connect')