/[SQLSession]/trunk/share/web/templates/sql
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 /trunk/share/web/templates/sql

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

revision 23 by dpavlin, Mon Dec 4 15:15:54 2006 UTC revision 27 by dpavlin, Thu Dec 7 19:51:05 2006 UTC
# Line 5  $sql_query => undef Line 5  $sql_query => undef
5  $name => undef  $name => undef
6  $database => undef  $database => undef
7    
8    $max_rows => 100
9    
10  </%args>  </%args>
11  <%init>  <%init>
12    
13  my $action = Jifty->web->new_action(  my $execute_sql = Jifty->web->new_action(
14          class => 'DoSQL',          class => 'DoSQL',
15          moniker => 'execute_sql',          moniker => 'execute_sql',
16  );  );
# Line 20  $sth = $result->content('sth') if $resul Line 22  $sth = $result->content('sth') if $resul
22    
23  <&| /_elements/wrapper, title => "Try out SQL query" &>  <&| /_elements/wrapper, title => "Try out SQL query" &>
24  <% Jifty->web->form->start() %>  <% Jifty->web->form->start() %>
25  <% $action->form_field('sql_query',  <% $execute_sql->form_field('sql_query',
26          default_value => $sql_query,          default_value => $sql_query,
27    #       cols => 80,
28    #       rows => 5,
29  ) %>  ) %>
30  <% $action->form_field('database',  <% $execute_sql->form_field('database',
31          default_value => $database,          default_value => $database,
32  ) %>  ) %>
33  <div class="submit_button">  <div class="submit_button">
34  <% $action->button( label => 'Try it!' ) %>  <% $execute_sql->button( label => 'Try it!' ) %>
35    
36    
37  % if ( defined($sth) ) {  % if ( defined($sth) ) {
38    
39    % warn "save SQL: ", $execute_sql->argument_value('sql_query');
40    
41  <% Jifty->web->link(  <% Jifty->web->link(
42          label => 'Save',          label => 'Save',
43          onclick => {          onclick => {
44                  region => 'save_query',                  region => 'save_query',
45                  replace_with => '/save',                  replace_with => '/save',
46                  args => {                  args => {
47                          sql_query => $action->argument_value('sql_query'),                          sql_query => $execute_sql->argument_value('sql_query'),
48                          database => $action->argument_value('database'),                          database => $execute_sql->argument_value('database'),
49                  },                  },
50                  refresh_self => 1,                  refresh_self => 1,
51                  toggle => 1,                  toggle => 1,
# Line 64  $sth = $result->content('sth') if $resul Line 70  $sth = $result->content('sth') if $resul
70  % }  % }
71  </tr>  </tr>
72    
73    % my $rows = 0;
74  % while ( my @row = $sth->fetchrow_array() ) {  % while ( my @row = $sth->fetchrow_array() ) {
75    %       last if (++$rows > $max_rows);
76  <tr>  <tr>
77  %       foreach my $v ( @row ) {  %       foreach my $v ( @row ) {
78  <td><% defined($v) ? $v : 'NULL' %></td>  <td><% defined($v) ? $v : 'NULL' %></td>
# Line 74  $sth = $result->content('sth') if $resul Line 82  $sth = $result->content('sth') if $resul
82    
83  </table>  </table>
84    
85    % if ($sth->rows > $max_rows) {
86    <div class="note">
87    Query produced more than <% $max_rows %> rows, try adding <tt>LIMIT</tt> and
88    <tt>OFFSET</tt> to see another part of results.
89    </div>
90    % }
91    
92  % } else {  % } else {
93    
94  </div><!-- submit_button -->  </div><!-- submit_button -->

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

  ViewVC Help
Powered by ViewVC 1.1.26