/[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 174 - (show annotations)
Mon Jun 16 16:48:16 2008 UTC (15 years, 10 months ago) by dpavlin
File size: 1190 byte(s)
big rename of StrixSite to StrixInstance, added sitemap and layout

rename creates huge diff, which is rather unfortunate, but we needed
to get terminology stright: sites are part of strix instances
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 instance =>
20 label is _('Strix instance'),
21 available are defer {
22 my $coll = Jifty->app_class('Model','StrixInstanceCollection')->new;
23 $coll->unlimit;
24 $coll->order_by( column => 'instance' );
25 [{
26 display_from => '_site_name',
27 value_from => 'instance',
28 collection => $coll,
29 }];
30 },
31 is mandatory,
32 render as 'Select';
33
34 param sql =>
35 label is _('SQL query'),
36 is mandatory,
37 render as 'Textarea';
38
39 };
40
41 sub sticky_on_success { 1 }
42 sub sticky_on_failure { 1 }
43
44 =head2 take_action
45
46 =cut
47
48 sub take_action {
49 my $self = shift;
50
51 return unless ( $self->result->success );
52
53 my $sql = A3C::SQL->new({
54 query => $self->argument_value('sql'),
55 dbh => Strix->dbh( $self->argument_value('instance') ),
56 encoding => 'iso-8859-2',
57 });
58
59 if ( $sql->count ) {
60 $self->result->content( 'sql' => $sql );
61 $self->result->message( _('Got %1 rows', $sql->count) );
62 } else {
63 $self->result->error( _('No results') );
64 }
65
66 }
67
68 1;
69

  ViewVC Help
Powered by ViewVC 1.1.26