/[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 23 by dpavlin, Sat Apr 18 23:14:41 2009 UTC revision 26 by dpavlin, Sat Apr 18 23:54:30 2009 UTC
# Line 76  if ( my $group_by = param('lookup_col') Line 76  if ( my $group_by = param('lookup_col')
76                  }, shift @data, # extract where                  }, shift @data, # extract where
77                  'group by', join(',', @group_by), qq{                  'group by', join(',', @group_by), qq{
78                  order by count($group_by) desc                  order by count($group_by) desc
79                  limit 10                  limit $limit
80                  }                  }
81          );          );
82    
# Line 86  if ( my $group_by = param('lookup_col') Line 86  if ( my $group_by = param('lookup_col')
86          my $sth = $dbh->prepare( $sql );          my $sth = $dbh->prepare( $sql );
87          $sth->execute( @data );          $sth->execute( @data );
88          $t = time() - $t;          $t = time() - $t;
89          print qq|$t<table><tr><th>|, join(qq|</th><th>|, @cols), qq|</th></tr>|;          print qq|<code>$sql<code>|;
90            print qq|<table><tr><th>|, join(qq|</th><th>|, @cols), qq|</th></tr>|;
91          while ( my @row = $sth->fetchrow_array ) {          while ( my @row = $sth->fetchrow_array ) {
92                  my $n = shift @row;                  my $n = shift @row;
93                  $n = 'NULL' unless defined $n;                  $n = 'NULL' unless defined $n;
94                  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>|;
95          }          }
96          print qq|</table>|;          print qq|</table>|;
97          print qq|<code>$sql</code>|;          print $sth->rows, qq| rows in $t s|;
98          exit;          exit;
99  }  }
100    
# Line 153  $t = time() - $t; Line 154  $t = time() - $t;
154    
155  print $sth->rows, qq| rows in $t s</code>|;  print $sth->rows, qq| rows in $t s</code>|;
156    
 #my @types = map { scalar $dbh->type_info($_)->{TYPE_NAME} } @{ $sth->{TYPE} };  
 my $types = dump( $sth->{TYPE} );  
 print qq{  
 <script type="text/javascript">  
 var column_type = $types ;  
 </script>  
 };  
   
157  @columns = @{ $sth->{NAME} } if $#columns == 0 && $columns[0] eq '*';  @columns = @{ $sth->{NAME} } if $#columns == 0 && $columns[0] eq '*';
158    
 print qq|<table id="results">|;  
   
 my $counter = 0;  
 sub table_row {  
         my $cell = shift;  
         my $class = $counter++ % 2 == 0 ? ' class=o' : '';  
         return  
                   qq|<tr $class><$cell>|  
                 . join( qq|</$cell><$cell>|, @_ )  
                 . qq|</$cell></tr>|  
                 ;  
   
 }  
   
 print table_row( 'th', @columns );  
   
 while ( my @row = $sth->fetchrow_array ) {  
         print table_row( 'td', @row );  
 }  
   
159  print  print
160          qq|</table>|            start_form( -id => 'sql', -class => 'fixed' )
         , start_form( -id => 'sql', -class => 'fixed' )  
161    
162          , qq|<input type=button value="[=]" onclick="\$('form#sql').toggleClass('fixed'); return false;" title="toggle fixed position" class="right">|          , qq|<input type=button value="[=]" onclick="\$('form#sql').toggleClass('fixed'); return false;" title="toggle fixed position" class="right">|
163          , qq|<input type=button value="[x]" onclick="\$('form#sql').toggleClass('visible'); return false;" title="hide sql editor" class="right">|          , qq|<input type=button value="[x]" onclick="\$('form#sql').toggleClass('visible'); return false;" title="hide sql editor" class="right">|
# Line 206  print Line 178  print
178                  <input type=button name=lookup_col title="lookup column details">                  <input type=button name=lookup_col title="lookup column details">
179                  <input type=button name=close_group_by value="[x]" disabled=1>                  <input type=button name=close_group_by value="[x]" disabled=1>
180                  <div id="lookup"></div>                  <div id="lookup"></div>
181                  <span>                  </span>
182          |          |
183    
184          , qq|<label for=group_by>group by</label>|          , qq|<label for=group_by>group by</label>|
# Line 224  print Line 196  print
196          , submit( -name => 'execute', -value => 'execute' )          , submit( -name => 'execute', -value => 'execute' )
197    
198          , end_form          , end_form
199            ;
200    
201    #my @types = map { scalar $dbh->type_info($_)->{TYPE_NAME} } @{ $sth->{TYPE} };
202    my $types = dump( $sth->{TYPE} );
203    print qq{
204    <script type="text/javascript">
205    var column_type = $types ;
206    </script>
207    };
208    
209    print qq|<table id="results">|;
210    
211    my $counter = 0;
212    sub table_row {
213            my $cell = shift;
214            my $class = $counter++ % 2 == 0 ? ' class=o' : '';
215            return
216                      qq|<tr $class><$cell>|
217                    . join( qq|</$cell><$cell>|, @_ )
218                    . qq|</$cell></tr>|
219                    ;
220    
221    }
222    
223    print table_row( 'th', @columns );
224    
225    while ( my @row = $sth->fetchrow_array ) {
226            print table_row( 'td', @row );
227    }
228    
229    print qq|</table>|
230          , qq|</body></html>|          , qq|</body></html>|
231          ;          ;

Legend:
Removed from v.23  
changed lines
  Added in v.26

  ViewVC Help
Powered by ViewVC 1.1.26