50 |
return @data; |
return @data; |
51 |
} |
} |
52 |
|
|
53 |
|
sub sql_html { |
54 |
|
my @d = @_; |
55 |
|
my $sql_html = shift @d; |
56 |
|
$sql_html =~ s{\?}{dump( shift @d )}ge; |
57 |
|
return $sql_html; |
58 |
|
} |
59 |
|
|
60 |
if ( my $group_by = param('lookup_col') ) { |
if ( my $group_by = param('lookup_col') ) { |
61 |
|
|
62 |
my @cols = ( $group_by, "count($group_by)" ); |
my @cols = ( $group_by, "count($group_by)" ); |
83 |
}, shift @data, # extract where |
}, shift @data, # extract where |
84 |
'group by', join(',', @group_by), qq{ |
'group by', join(',', @group_by), qq{ |
85 |
order by count($group_by) desc |
order by count($group_by) desc |
86 |
limit 10 |
limit $limit |
87 |
} |
} |
88 |
); |
); |
89 |
|
|
93 |
my $sth = $dbh->prepare( $sql ); |
my $sth = $dbh->prepare( $sql ); |
94 |
$sth->execute( @data ); |
$sth->execute( @data ); |
95 |
$t = time() - $t; |
$t = time() - $t; |
96 |
print qq|$t<table><tr><th>|, join(qq|</th><th>|, @cols), qq|</th></tr>|; |
print qq|<code>|, sql_html( $sql, @data ), qq|<code>|; |
97 |
|
print qq|<table><tr><th>|, join(qq|</th><th>|, @cols), qq|</th></tr>|; |
98 |
while ( my @row = $sth->fetchrow_array ) { |
while ( my @row = $sth->fetchrow_array ) { |
99 |
my $n = shift @row; |
my $n = shift @row; |
100 |
$n = 'NULL' unless defined $n; |
$n = 'NULL' unless defined $n; |
101 |
print qq|<tr><td><a href="#">$n</a></td><td>|, join(qq|</td><td>|, @row), qq|</td></tr>|; |
print qq|<tr><td><a href="#">$n</a></td><td>|, join(qq|</td><td>|, @row), qq|</td></tr>|; |
102 |
} |
} |
103 |
print qq|</table>|; |
print qq|</table>|; |
104 |
print qq|<code>$sql</code>|; |
print $sth->rows, qq| rows in $t s|; |
105 |
exit; |
exit; |
106 |
} |
} |
107 |
|
|
144 |
|
|
145 |
push @data, ( $limit, $offset ); |
push @data, ( $limit, $offset ); |
146 |
|
|
147 |
my $sql_html = $sql; |
print qq|<code id="status">|, sql_html( $sql, @data ), qq|<br>\n|; |
|
{ |
|
|
my @d = @data; |
|
|
$sql_html =~ s{\?}{dump( shift @d )}ge; |
|
|
} |
|
|
print qq|<code id="status">$sql_html<br>\n\r\n\r|; |
|
148 |
|
|
149 |
my $t = time(); |
my $t = time(); |
150 |
|
|