Skip to content

Commit

Permalink
fix query counting again
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis committed May 4, 2009
1 parent 4b34df2 commit ee7bc38
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
4 changes: 4 additions & 0 deletions core/database_api.php
Expand Up @@ -273,6 +273,8 @@ function db_query( $p_query, $p_limit = -1, $p_offset = -1 ) {
$t_elapsed = number_format( microtime(true) - $t_start, 4 );

array_push( $g_queries_array, array( $p_query, $t_elapsed, $t_caller ) );
} else {
array_push( $g_queries_array, 1 );
}

if( !$t_result ) {
Expand Down Expand Up @@ -372,6 +374,8 @@ function db_query_bound( $p_query, $arr_parms = null, $p_limit = -1, $p_offset =
}

array_push( $g_queries_array, array( $p_query, $t_elapsed, $t_caller ) );
} else {
array_push( $g_queries_array, 1 );
}

# We can't reset the counter because we have queries being built
Expand Down
23 changes: 12 additions & 11 deletions core/html_api.php
Expand Up @@ -578,18 +578,19 @@ function html_footer( $p_file ) {
if( helper_show_queries() ) {
$t_count = count( $g_queries_array );
echo "\t", $t_count, ' ', lang_get( 'total_queries_executed' ), '<br />', "\n";
$t_unique_queries = 0;
$t_shown_queries = array();
for( $i = 0;$i < $t_count;$i++ ) {
if( !in_array( $g_queries_array[$i][0], $t_shown_queries ) ) {
$t_unique_queries++;
$g_queries_array[$i][3] = false;
array_push( $t_shown_queries, $g_queries_array[$i][0] );
} else {
$g_queries_array[$i][3] = true;
}
}
if( ON == config_get( 'show_queries_list' ) ) {
$t_unique_queries = 0;
$t_shown_queries = array();
for( $i = 0;$i < $t_count;$i++ ) {
if( !in_array( $g_queries_array[$i][0], $t_shown_queries ) ) {
$t_unique_queries++;
$g_queries_array[$i][3] = false;
array_push( $t_shown_queries, $g_queries_array[$i][0] );
} else {
$g_queries_array[$i][3] = true;
}
}

echo "\t", $t_unique_queries, ' ', lang_get( 'unique_queries_executed' ), '<br />', "\n";
echo "\t", '<table>', "\n";
$t_total = 0;
Expand Down

0 comments on commit ee7bc38

Please sign in to comment.