1 |
<%args> |
2 |
$page => 1 |
3 |
$sth => undef |
4 |
</%args> |
5 |
<%init> |
6 |
|
7 |
my $action = Jifty->web->new_action( |
8 |
class => 'DoSQL', |
9 |
moniker => 'execute_sql', |
10 |
); |
11 |
|
12 |
my $result = Jifty->web->response->result('execute_sql'); |
13 |
$sth = $result->content('sth') if $result and !defined $sth; |
14 |
|
15 |
</%init> |
16 |
|
17 |
<&| /_elements/wrapper, title => "Try out SQL query" &> |
18 |
<% Jifty->web->form->start() %> |
19 |
<% $action->form_field('sql_query') %> |
20 |
<% $action->form_field('database') %> |
21 |
<% Jifty->web->form->submit( label => 'Try it!' ) %> |
22 |
<% Jifty->web->form->end() %> |
23 |
</&> |
24 |
|
25 |
% if ( defined($sth) ) { |
26 |
|
27 |
<table cellpadding="3" cellspacing="0" border="1"> |
28 |
|
29 |
<tr> |
30 |
% foreach my $col ( @{ $sth->{'NAME'} } ) { |
31 |
<th><% $col %></th> |
32 |
% } |
33 |
</tr> |
34 |
|
35 |
% while ( my @row = $sth->fetchrow_array() ) { |
36 |
<tr> |
37 |
% foreach my $v ( @row ) { |
38 |
<td><% defined($v) ? $v : 'NULL' %></td> |
39 |
% } |
40 |
</tr> |
41 |
% } |
42 |
|
43 |
</table> |
44 |
|
45 |
% } |