From 55a8c6267fad29d8bc3677c084c2c5d00569ec96 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Nov 2012 13:31:21 +0200 Subject: Display DB object names in the Profiler and fix issue #1220 --- system/libraries/Profiler.php | 31 +++++++++++++++++++++++-------- user_guide_src/source/changelog.rst | 2 ++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 7d7069b95..1c97e3481 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -75,12 +75,14 @@ class CI_Profiler { */ protected $CI; + // -------------------------------------------------------------------- + /** - * Constructor + * Class constructor * * Initialize Profiler * - * @param array $config + * @param array $config Parameters */ public function __construct($config = array()) { @@ -112,7 +114,7 @@ class CI_Profiler { * * Sets the private _compile_* properties to enable/disable Profiler sections * - * @param mixed + * @param mixed $config * @return void */ public function set_sections($config) @@ -191,11 +193,24 @@ class CI_Profiler { $dbs = array(); // Let's determine which databases are currently connected to - foreach (get_object_vars($this->CI) as $CI_object) + foreach (get_object_vars($this->CI) as $name => $cobject) { - if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB')) + if (is_object($cobject)) { - $dbs[] = $CI_object; + if ($cobject instanceof CI_DB) + { + $dbs[get_class($this->CI).':$'.$name] = $cobject; + } + elseif ($cobject instanceof CI_Model) + { + foreach (get_object_vars($cobject) as $mname => $mobject) + { + if ($mobject instanceof CI_DB) + { + $dbs[get_class($cobject).':$'.$mname] = $mobject; + } + } + } } } @@ -220,7 +235,7 @@ class CI_Profiler { $output = "\n\n"; $count = 0; - foreach ($dbs as $db) + foreach ($dbs as $name => $db) { $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; @@ -234,7 +249,7 @@ class CI_Profiler { $output .= '
' ."\n" .'  '.$this->CI->lang->line('profiler_database') - .':  '.$db->database.'   '.$this->CI->lang->line('profiler_queries') + .':  '.$db->database.' ('.$name.')   '.$this->CI->lang->line('profiler_queries') .': '.count($db->queries).'  '.$show_hide_js."\n\n\n" .'\n"; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 570aef57a..a569592c2 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -237,6 +237,7 @@ Release Date: Not Released - Added support for hashing algorithms other than SHA1 and MD5. - Removed previously deprecated ``sha1()`` method. - Changed :doc:`Language Library ` method ``load()`` to filter the language name with ``ctype_digit()``. + - :doc:`Profiler Library ` now also displays database object names. - Core @@ -424,6 +425,7 @@ Bug fixes for 3.0 - Fixed a bug (#122) - :doc:`URI Library ` method ``ruri_string()`` didn't include a directory if one is used. - Fixed a bug - :doc:`Routing Library ` didn't properly handle *default_controller* in a subdirectory when a method is also specified. - Fixed a bug (#953) - :doc:`post_controller_constructor hook ` wasn't called with a *404_override*. +- Fixed a bug (#1220) - :doc:`Profiler Library ` didn't display information for database objects that are instantiated inside models. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b