(function($) {

    var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-widgets-');

    /**
     * Widget for the displaying sql queries
     *
     * Options:
     *  - data
     */
    var SQLQueriesWidget = PhpDebugBar.Widgets.SQLQueriesWidget = PhpDebugBar.Widget.extend({

        className: csscls('sqlqueries'),

        render: function() {
            this.$status = $('<div />').addClass(csscls('status')).appendTo(this.$el);

            this.$list = new  PhpDebugBar.Widgets.ListWidget({ itemRenderer: function(li, stmt) {
                $('<code />').addClass(csscls('sql')).html(PhpDebugBar.Widgets.highlight(stmt.sql, 'sql')).appendTo(li);
                if (stmt.duration_str) {
                    $('<span title="Duration" />').addClass(csscls('duration')).text(stmt.duration_str).appendTo(li);
                }
                if (stmt.memory_str) {
                    $('<span title="Memory usage" />').addClass(csscls('memory')).text(stmt.memory_str).appendTo(li);
                }
                if (typeof(stmt.is_success) != 'undefined' && !stmt.is_success) {
                    li.addClass(csscls('error'));
                    li.append($('<span />').addClass(csscls('error')).text("[" + stmt.error_code + "] " + stmt.error_message));
                } else if (typeof(stmt.row_count) != 'undefined') {
                    $('<span title="Row count" />').addClass(csscls('row-count')).text(stmt.row_count).appendTo(li);
                }
                if (typeof(stmt.stmt_id) != 'undefined' && stmt.stmt_id) {
                    $('<span title="Prepared statement ID" />').addClass(csscls('stmt-id')).text(stmt.stmt_id).appendTo(li);
                }
                if (stmt.params && !$.isEmptyObject(stmt.params)) {
                    var table = $('<table><tr><th colspan="2">Params</th></tr></table>').addClass(csscls('params')).appendTo(li);
                    for (var key in stmt.params) {
                        table.append('<tr><td class="' + csscls('name') + '">' + key + '</td><td class="' + csscls('value') + 
                                     '">' + stmt.params[key] + '</td></tr>');
                    }
                    li.css('cursor', 'pointer').click(function() {
                        if (table.is(':visible')) {
                            table.hide();
                        } else {
                            table.show();
                        }
                    });
                }
            }});
            this.$list.$el.appendTo(this.$el);

            this.bindAttr('data', function(data) {
                this.$list.set('data', data.statements);
                this.$status.empty();

                var t = $('<span />').text(data.nb_statements + " statements were executed").appendTo(this.$status);
                if (data.nb_failed_statements) {
                    t.append(", " + data.nb_failed_statements + " of which failed");
                }
                if (data.accumulated_duration_str) {
                    this.$status.append($('<span title="Accumulated duration" />').addClass(csscls('duration')).text(data.accumulated_duration_str));
                }
                if (data.memory_usage_str) {
                    this.$status.append($('<span title="Memory usage" />').addClass(csscls('memory')).text(data.memory_usage_str));
                }
            });
        }

    });

})(PhpDebugBar.$);

@@ -2674,24 +2674,889 @@
 s.empty();%0A%0A
+                // Search for duplicate statements.%0A                for (var sql = %7B%7D, duplicate = 0, i = 0; i %3C data.statements.length; i++) %7B%0A                    var stmt = data.statements%5Bi%5D.sql;%0A                    sql%5Bstmt%5D = sql%5Bstmt%5D %7C%7C %7B keys: %5B%5D %7D;%0A                    sql%5Bstmt%5D.keys.push(i);%0A                %7D%0A                // Add classes to all duplicate SQL statements.%0A                for (var stmt in sql) %7B%0A                    if (sql%5Bstmt%5D.keys.length %3E 1) %7B%0A                        duplicate++;%0A                        for (var i = 0; i %3C sql%5Bstmt%5D.keys.length; i++) %7B%0A                            this.$list.$el.find('.' + csscls('list-item')).eq(sql%5Bstmt%5D.keys%5Bi%5D)%0A                                .addClass(csscls('sql-duplicate')).addClass(csscls('sql-duplicate-'+duplicate));%0A                        %7D%0A                    %7D%0A                %7D%0A%0A
             
@@ -3804,32 +3804,161 @@
               %7D%0A
+                if (duplicate) %7B%0A                    t.append(%22, %22 + duplicate + %22 of which were duplicates%22);%0A                %7D%0A
                 

Add classes to all duplicate SQL statement rows.