/[A3C]/lib/A3C/Action/StrixSQL.pm
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 /lib/A3C/Action/StrixSQL.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 167 - (show annotations)
Sun Jun 15 23:19:02 2008 UTC (15 years, 10 months ago) by dpavlin
File size: 1136 byte(s)
move Strix specific stuff to own package
1 use strict;
2 use warnings;
3
4 =head1 NAME
5
6 A3C::Action::StrixSQL
7
8 =cut
9
10 package A3C::Action::StrixSQL;
11 use base qw/A3C::Action Jifty::Action/;
12
13 use Strix;
14 use Data::Dump qw/dump/;
15
16 use Jifty::Param::Schema;
17 use Jifty::Action schema {
18
19 param strix =>
20 label is _('Strix site'),
21 available are defer {
22 my $coll = Jifty->app_class('Model','StrixSiteCollection')->new;
23 $coll->unlimit;
24 $coll->order_by( column => 'site' );
25 [{
26 display_from => '_site_name',
27 value_from => 'site',
28 collection => $coll,
29 }];
30 },
31 render as 'Select';
32
33 param sql =>
34 label is _('SQL query'),
35 render as 'Textarea';
36
37 };
38
39 sub sticky_on_success { 1 }
40 sub sticky_on_failure { 1 }
41
42 =head2 take_action
43
44 =cut
45
46 sub take_action {
47 my $self = shift;
48
49 return unless ( $self->result->success );
50
51 my $sql = A3C::SQL->new({
52 query => $self->argument_value('sql'),
53 dbh => Strix->dbh( $self->argument_value('strix') ),
54 encoding => 'iso-8859-2',
55 });
56
57 if ( $sql->count ) {
58 $self->result->content( 'sql' => $sql );
59 $self->result->message( _('Got %1 rows', $sql->count) );
60 } else {
61 $self->result->error( _('No results') );
62 }
63
64 }
65
66 1;
67

  ViewVC Help
Powered by ViewVC 1.1.26