/[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 220 - (show annotations)
Sun Jun 22 14:55:55 2008 UTC (15 years, 10 months ago) by dpavlin
File size: 1313 byte(s)
display duration of SQL query
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 $instance = $self->argument_value('instance');
54 $self->result->content( 'instance' => $instance );
55
56 my $sql = A3C::SQL->new({
57 query => $self->argument_value('sql'),
58 dbh => Strix->dbh( $instance ),
59 encoding => 'iso-8859-2',
60 });
61
62 if ( $sql->count ) {
63 $self->result->content( 'sql' => $sql );
64 $self->result->message( _('Got %1 rows from %2 in %3 s', $sql->count, $instance, $sql->duration) );
65 } else {
66 $self->result->error( _('No results') );
67 }
68
69 }
70
71 1;
72

  ViewVC Help
Powered by ViewVC 1.1.26