/[Frey]/trunk/lib/Frey/SQL.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 /trunk/lib/Frey/SQL.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1133 - (show annotations)
Tue Jun 30 15:10:55 2009 UTC (14 years, 10 months ago) by dpavlin
File size: 839 byte(s)
make classes immutable and remove moose droppings to make Perl::Critic::Moose happy
1 package Frey::SQL;
2 use Moose;
3 extends 'Frey';
4
5 with 'Frey::Web';
6
7 use DBI;
8 use Data::Dump qw/dump/;
9
10 has 'sponge' => (
11 is => 'rw',
12 isa => 'Sponge',
13 required => 1,
14 );
15
16 has 'query' => (
17 is => 'rw',
18 isa => 'Str',
19 required => 1,
20 default => 'select * from sponge',
21 documentation => 'SQL query to filter data',
22 );
23
24 has table => (
25 is => 'rw',
26 isa => 'Str',
27 required => 1,
28 default => 'sponge',
29 documentation => 'Name of table to create from sponge data',
30 );
31
32 sub as_data {
33 my ($self) = @_;
34
35 my $dbh=DBI->connect('dbi:AnyData(RaiseError=>1):');
36
37 my $data = $self->sponge->{rows};
38 unshift @$data, $self->sponge->{NAME};
39
40 warn "# data = ",dump( $data ) if $self->debug;
41
42 $dbh->func( $self->table, 'ARRAY', $data, 'ad_import' );
43
44 return $dbh->selectall_arrayref( $self->query );
45 }
46
47 __PACKAGE__->meta->make_immutable;
48 no Moose;
49
50 1;

  ViewVC Help
Powered by ViewVC 1.1.26