From d90ad1e1391d555dcc8b89bfcd70a1414b8fde25 Mon Sep 17 00:00:00 2001 From: JCSama Date: Sun, 11 Feb 2018 15:49:40 +0100 Subject: [PATCH] Issue #25 : Profiling database not possible when using PDO --- CHANGELOG.md | 12 ++++++++ third_party/DevelBar/hooks/Develbar.php | 22 ++++++++++---- .../DevelBar/views/develbar/database.php | 10 +++---- .../DevelBar/views/develbar/profiler.php | 29 ++++++++++++------- version.json | 2 +- 5 files changed, 54 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a97dfc..1b97782 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## 1.2 (2017-01-18) + +Fix: + +- Profiling database not possible when using PDO + +## 1.1 (2017-01-18) + +Fix: + +- Profiler link not visible on ajax pannel (JS Error) + ## 1.0 (2017-03-21) Changes: diff --git a/third_party/DevelBar/hooks/Develbar.php b/third_party/DevelBar/hooks/Develbar.php index f44b02d..f4790f9 100755 --- a/third_party/DevelBar/hooks/Develbar.php +++ b/third_party/DevelBar/hooks/Develbar.php @@ -38,7 +38,7 @@ class Develbar /** * DevelBar version */ - const VERSION = '1.1'; + const VERSION = '1.2'; /** * Supported CI version @@ -365,12 +365,26 @@ protected function database_section($return_view = true) if ($cobject instanceof CI_DB) { $controller = &get_instance(); if ($controller instanceof CI_Controller) { - $dbs[get_class($this->CI) . ':$' . $name] = $cobject; + $database = array( + 'database' => $cobject->database, + 'hostname' => $cobject->hostname, + 'queries' => $cobject->queries, + 'query_times' => $cobject->query_times, + 'query_count' => $cobject->query_count, + ); + $dbs[get_class($this->CI) . ':$' . $name] = $database; } } elseif ($cobject instanceof CI_Model) { foreach (get_object_vars($cobject) as $mname => $mobject) { if ($mobject instanceof CI_DB) { - $dbs[get_class($cobject) . ':$' . $mname] = $mobject; + $database = array( + 'database' => $mobject->database, + 'hostname' => $mobject->hostname, + 'queries' => $mobject->queries, + 'query_times' => $mobject->query_times, + 'query_count' => $mobject->query_count, + ); + $dbs[get_class($cobject) . ':$' . $mname] = $database; } } } @@ -403,7 +417,6 @@ protected function hooks_section() if (!isset($_hooks[0])) { $_hooks = array($_hooks); } - foreach ($_hooks as $hook) { if (!array_key_exists('class', $hook)) { $hooks[$hook_point][] = $hook; @@ -414,7 +427,6 @@ protected function hooks_section() $total_hooks++; } } - } $data = array( diff --git a/third_party/DevelBar/views/develbar/database.php b/third_party/DevelBar/views/develbar/database.php index 4b1ea19..d6ab319 100755 --- a/third_party/DevelBar/views/develbar/database.php +++ b/third_party/DevelBar/views/develbar/database.php @@ -6,12 +6,12 @@ $db): - if (count($db->queries)) { - echo '-' . $db->hostname . '#' . lang('database') . ' : ' . $db->database . '
'; + if (count($db['queries'])) { + echo '-' . $db['hostname'] . '#' . lang('database') . ' : ' . $db['database'] . '
'; $total_execution_time = 0; echo '
'; - foreach ($db->queries as $key => $query) { - $time = number_format($db->query_times[$key], 4); + foreach ($db['queries'] as $key => $query) { + $time = number_format($db['query_times'][$key], 4); $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); //$query = highlight_code($query); foreach ($highlight as $bold) { @@ -23,7 +23,7 @@ ' . $time . ' ' .lang('sec') .'

'; } - $total_execution_time = array_sum($db->query_times); + $total_execution_time = array_sum($db['query_times']); $global_execution_time += $total_execution_time; echo '
diff --git a/third_party/DevelBar/views/develbar/profiler.php b/third_party/DevelBar/views/develbar/profiler.php index 41f419c..97e08fc 100644 --- a/third_party/DevelBar/views/develbar/profiler.php +++ b/third_party/DevelBar/views/develbar/profiler.php @@ -16,7 +16,7 @@ } .ci-toolbar-tabs li a{ color:#90949f; display:block; padding:14px 40px; text-decoration:none; border-right:4px solid transparent } .ci-toolbar-tabs li a.ajax{ background:url("") no-repeat 10px center } - .ci-toolbar-tabs li a.database{ background:url("") no-repeat 10px center } + .ci-toolbar-tabs li a.database{ background:url("") no-repeat 10px center } .ci-toolbar-tabs li a.models{ background:url("") no-repeat 10px center } .ci-toolbar-tabs li a.helpers{ background:url("") no-repeat 10px center } .ci-toolbar-tabs li a.libraries{ background:url("") no-repeat 10px center } @@ -42,7 +42,9 @@