/[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

Contents of /trunk/share/web/templates/sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 26 - (show annotations)
Mon Dec 4 19:24:25 2006 UTC (17 years, 5 months ago) by dpavlin
File size: 1694 byte(s)
display maximum of 100 rows, and show note how to get other results
1 <%args>
2 $sth => undef
3
4 $sql_query => undef
5 $name => undef
6 $database => undef
7
8 $max_rows => 100
9
10 </%args>
11 <%init>
12
13 my $action = Jifty->web->new_action(
14 class => 'DoSQL',
15 moniker => 'execute_sql',
16 );
17
18 my $result = Jifty->web->response->result('execute_sql');
19 $sth = $result->content('sth') if $result and !defined $sth;
20
21 </%init>
22
23 <&| /_elements/wrapper, title => "Try out SQL query" &>
24 <% Jifty->web->form->start() %>
25 <% $action->form_field('sql_query',
26 default_value => $sql_query,
27 ) %>
28 <% $action->form_field('database',
29 default_value => $database,
30 ) %>
31 <div class="submit_button">
32 <% $action->button( label => 'Try it!' ) %>
33
34
35 % if ( defined($sth) ) {
36
37 <% Jifty->web->link(
38 label => 'Save',
39 onclick => {
40 region => 'save_query',
41 replace_with => '/save',
42 args => {
43 sql_query => $action->argument_value('sql_query'),
44 database => $action->argument_value('database'),
45 },
46 refresh_self => 1,
47 toggle => 1,
48 },
49 as_button => 1,
50 ) %>
51
52 </div>
53 <% Jifty->web->form->end() %>
54
55 <% Jifty->web->region(
56 name => 'save_query',
57 ) %>
58
59 </div>
60
61 <table cellpadding="3" cellspacing="0" border="1">
62
63 <tr>
64 % foreach my $col ( @{ $sth->{'NAME'} } ) {
65 <th><% $col %></th>
66 % }
67 </tr>
68
69 % my $rows = 0;
70 % while ( my @row = $sth->fetchrow_array() ) {
71 % last if (++$rows > $max_rows);
72 <tr>
73 % foreach my $v ( @row ) {
74 <td><% defined($v) ? $v : 'NULL' %></td>
75 % }
76 </tr>
77 % }
78
79 </table>
80
81 % if ($sth->rows > $max_rows) {
82 <div class="note">
83 Query produced more than <% $max_rows %> rows, try adding <tt>LIMIT</tt> and
84 <tt>OFFSET</tt> to see another part of results.
85 </div>
86 % }
87
88 % } else {
89
90 </div><!-- submit_button -->
91 <% Jifty->web->form->end() %>
92
93 % }
94
95 <% Jifty->web->return( label => "Go back" ) %>
96
97 </&>
98

  ViewVC Help
Powered by ViewVC 1.1.26