/[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 920 - (show annotations)
Mon Jan 5 20:22:37 2009 UTC (15 years, 4 months ago) by dpavlin
File size: 759 byte(s)
make sponge param with new validation role Frey::Sponge
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 with 'Frey::Sponge'; # has sponge
11
12 has 'query' => (
13 is => 'rw',
14 isa => 'Str',
15 required => 1,
16 default => 'select * from sponge',
17 documentation => 'SQL query to filter data',
18 );
19
20 has table => (
21 is => 'rw',
22 isa => 'Str',
23 required => 1,
24 default => 'sponge',
25 documentation => 'Name of table to create from sponge data',
26 );
27
28 sub as_data {
29 my ($self) = @_;
30
31 my $dbh=DBI->connect('dbi:AnyData(RaiseError=>1):');
32
33 my $data = $self->sponge->{rows};
34 unshift @$data, $self->sponge->{NAME};
35
36 warn "# data = ",dump( $data ) if $self->debug;
37
38 $dbh->func( $self->table, 'ARRAY', $data, 'ad_import' );
39
40 return $dbh->selectall_arrayref( $self->query );
41 }
42
43 1;

  ViewVC Help
Powered by ViewVC 1.1.26