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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 78 - (show annotations)
Mon Jan 29 20:11:20 2007 UTC (17 years, 3 months ago) by dpavlin
File size: 1368 byte(s)
re-organize SQL query page into fragments
1 <%args>
2 $sth => undef
3 $q => undef
4 $max_rows => 100
5 </%args>
6 <%init>
7
8 my $query = Jifty->web->new_action(
9 class => 'DoSQL',
10 moniker => 'query',
11 );
12
13 my $result = Jifty->web->response->result('query');
14 $sth = $result->content('sth') if $result and !defined $sth;
15
16 my $edit = Jifty->web->current_user->role('edit');
17 warn $edit ? 'edit mode for SQL' : 'student mode';
18
19 use Data::Dump qw/dump/;
20 warn "q = ", dump( $q );
21
22 </%init>
23
24 % if ($sth) {
25
26 % if ($edit) {
27 <% Jifty->web->link(
28 label => 'Save this query',
29 onclick => {
30 region => 'query',
31 replace_with => '/fragments/save_query',
32 args => {
33 sql_query => $query->argument_value('sql_query'),
34 database => $query->argument_value('database'),
35 },
36 refresh_self => 0,
37 #toggle => 1,
38 disable => 1,
39 refresh => 'results',
40 },
41 as_button => 1,
42 ) %>
43 % }
44
45 <table class="sql-result-table" cellpadding="3" cellspacing="0" border="1">
46
47 <tr>
48 % foreach my $col ( @{ $sth->{'NAME'} } ) {
49 <th><% $col %></th>
50 % }
51 </tr>
52
53 % my $rows = 0;
54 % while ( my @row = $sth->fetchrow_array() ) {
55 % last if (++$rows > $max_rows);
56 <tr>
57 % foreach my $v ( @row ) {
58 <td><% defined($v) ? $v : 'NULL' %></td>
59 % }
60 </tr>
61 % }
62
63 </table>
64
65 % if ($sth->rows > $max_rows) {
66 <div class="note">
67 Query produced more than <% $max_rows %> rows, try adding <tt>LIMIT</tt> and
68 <tt>OFFSET</tt> to see another part of results.
69 </div>
70 % }
71
72
73 % } # if $sth

  ViewVC Help
Powered by ViewVC 1.1.26