/[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

Annotation of /lib/A3C/Action/StrixSQL.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 174 - (hide 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 dpavlin 161 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 dpavlin 167 use Strix;
14 dpavlin 161 use Data::Dump qw/dump/;
15    
16     use Jifty::Param::Schema;
17     use Jifty::Action schema {
18    
19 dpavlin 174 param instance =>
20     label is _('Strix instance'),
21 dpavlin 161 available are defer {
22 dpavlin 174 my $coll = Jifty->app_class('Model','StrixInstanceCollection')->new;
23 dpavlin 161 $coll->unlimit;
24 dpavlin 174 $coll->order_by( column => 'instance' );
25 dpavlin 161 [{
26     display_from => '_site_name',
27 dpavlin 174 value_from => 'instance',
28 dpavlin 161 collection => $coll,
29     }];
30     },
31 dpavlin 174 is mandatory,
32 dpavlin 161 render as 'Select';
33    
34     param sql =>
35     label is _('SQL query'),
36 dpavlin 174 is mandatory,
37 dpavlin 161 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 dpavlin 174 dbh => Strix->dbh( $self->argument_value('instance') ),
56 dpavlin 162 encoding => 'iso-8859-2',
57 dpavlin 161 });
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