/[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 27 - (show annotations)
Thu Dec 7 19:51:05 2006 UTC (17 years, 5 months ago) by dpavlin
File size: 1816 byte(s)
rename action to be consistent with moniker
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 $execute_sql = 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 <% $execute_sql->form_field('sql_query',
26 default_value => $sql_query,
27 # cols => 80,
28 # rows => 5,
29 ) %>
30 <% $execute_sql->form_field('database',
31 default_value => $database,
32 ) %>
33 <div class="submit_button">
34 <% $execute_sql->button( label => 'Try it!' ) %>
35
36
37 % if ( defined($sth) ) {
38
39 % warn "save SQL: ", $execute_sql->argument_value('sql_query');
40
41 <% Jifty->web->link(
42 label => 'Save',
43 onclick => {
44 region => 'save_query',
45 replace_with => '/save',
46 args => {
47 sql_query => $execute_sql->argument_value('sql_query'),
48 database => $execute_sql->argument_value('database'),
49 },
50 refresh_self => 1,
51 toggle => 1,
52 },
53 as_button => 1,
54 ) %>
55
56 </div>
57 <% Jifty->web->form->end() %>
58
59 <% Jifty->web->region(
60 name => 'save_query',
61 ) %>
62
63 </div>
64
65 <table cellpadding="3" cellspacing="0" border="1">
66
67 <tr>
68 % foreach my $col ( @{ $sth->{'NAME'} } ) {
69 <th><% $col %></th>
70 % }
71 </tr>
72
73 % my $rows = 0;
74 % while ( my @row = $sth->fetchrow_array() ) {
75 % last if (++$rows > $max_rows);
76 <tr>
77 % foreach my $v ( @row ) {
78 <td><% defined($v) ? $v : 'NULL' %></td>
79 % }
80 </tr>
81 % }
82
83 </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 {
93
94 </div><!-- submit_button -->
95 <% Jifty->web->form->end() %>
96
97 % }
98
99 <% Jifty->web->return( label => "Go back" ) %>
100
101 </&>
102

  ViewVC Help
Powered by ViewVC 1.1.26