1 |
<%args> |
2 |
</%args> |
3 |
<%init> |
4 |
|
5 |
my $query = Jifty->web->new_action( |
6 |
class => 'DoSQL', |
7 |
moniker => 'csv', |
8 |
arguments => { %ARGS }, |
9 |
); |
10 |
|
11 |
$query->run or die "can't DoSQL"; |
12 |
my $sth = $query->result->content('sth') or die "no sth in result->content?"; |
13 |
|
14 |
use Data::Dump qw/dump/; |
15 |
warn "sth = ", dump( $sth ); |
16 |
|
17 |
my @out; |
18 |
|
19 |
if ($sth) { |
20 |
|
21 |
push @out, join(",", map { "\"$_\"" } @{ $sth->{'NAME'} } ); |
22 |
|
23 |
while ( my @row = $sth->fetchrow_array() ) { |
24 |
push @out, join(",", map { "\"$_\"" } @row ); |
25 |
} |
26 |
|
27 |
} |
28 |
|
29 |
Jifty->handler->apache->content_type('text/csv; charset=utf-8'); |
30 |
|
31 |
</%init> |
32 |
<% join("\r\n", @out) |n %> |