Skip to content

Commit

Permalink
Fixing issue where Data::append is not really appending. Fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
mariano committed Jan 10, 2012
1 parent a306cbe commit cafcf42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions extensions/util/Data.php
Expand Up @@ -7,13 +7,13 @@
namespace li3_perf\extensions\util; namespace li3_perf\extensions\util;


class Data extends \lithium\core\StaticObject { class Data extends \lithium\core\StaticObject {

static $data = array( static $data = array(
'view_vars' => array(), 'view_vars' => array(),
'queries' => array(), 'queries' => array(),
'timers' => array() 'timers' => array()
); );

/** /**
* Sets data. * Sets data.
*/ */
Expand All @@ -24,23 +24,23 @@ static public function set($key=null, $value=null) {
} }
return false; return false;
} }

/** /**
* Appends data. * Appends data.
*/ */
static public function append($key=null, $value=null) { static public function append($key=null, $value=null) {
if(!empty($key)) { if(!empty($key)) {
static::$data[$key] += $value; static::$data[$key] = array_merge(static::$data[$key], $value);
return true; return true;
} }
return false; return false;
} }

/** /**
* Gets data. * Gets data.
*/ */
static public function get($key=null) { static public function get($key=null) {
return (isset(static::$data[$key])) ? static::$data[$key]:false; return (isset(static::$data[$key])) ? static::$data[$key]:false;
} }
} }
?> ?>
4 changes: 3 additions & 1 deletion views/elements/queries.html.php
Expand Up @@ -2,7 +2,9 @@
$total_queries = count($queries); $total_queries = count($queries);
$total_query_time = 0; $total_query_time = 0;
foreach($queries as $query) { foreach($queries as $query) {
$total_query_time += $query['explain']['millis']; $total_query_time += !empty($query['explain']['millis']) ?
$query['explain']['millis'] :
0;
} }
?> ?>
<h2>Queries</h2> <h2>Queries</h2>
Expand Down

0 comments on commit cafcf42

Please sign in to comment.