/[sql-web-session]/index.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /index.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 24 by dpavlin, Sat Apr 18 23:21:40 2009 UTC revision 27 by dpavlin, Sat Apr 18 23:58:42 2009 UTC
# Line 50  sub where_from_parts { Line 50  sub where_from_parts {
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)" );
# Line 76  if ( my $group_by = param('lookup_col') Line 83  if ( my $group_by = param('lookup_col')
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    
# Line 86  if ( my $group_by = param('lookup_col') Line 93  if ( my $group_by = param('lookup_col')
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    
# Line 136  $sql .= ' limit ? offset ?'; Line 144  $sql .= ' limit ? offset ?';
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    

Legend:
Removed from v.24  
changed lines
  Added in v.27

  ViewVC Help
Powered by ViewVC 1.1.26