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

Annotation of /trunk/lib/Frey/SQL.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 374 - (hide annotations)
Mon Nov 17 15:42:41 2008 UTC (15 years, 6 months ago) by dpavlin
File size: 882 byte(s)
added documentation
1 dpavlin 370 package Frey::SQL;
2     use Moose;
3    
4     use MooseX::Types::Moose qw(Str Int ArrayRef);
5     use MooseX::Types::Structured qw/Dict/;
6    
7     use DBI;
8     use Data::Dump qw/dump/;
9    
10     has 'query' => (
11     is => 'rw',
12     isa => 'Str',
13     required => 1,
14 dpavlin 371 default => 'select * from sponge',
15 dpavlin 374 documentation => 'SQL query to filter data',
16 dpavlin 370 );
17    
18     has table => (
19     is => 'rw',
20     isa => 'Str',
21     required => 1,
22     default => 'sponge',
23 dpavlin 374 documentation => 'Name of table to create from sponge data',
24 dpavlin 370 );
25    
26     has 'sponge' => (
27     is => 'rw',
28     isa => Dict[
29     rows => ArrayRef[ArrayRef],
30     NAME => ArrayRef[Str],
31     ],
32     required => 1,
33     );
34    
35     sub data {
36     my ($self) = @_;
37    
38     my $dbh=DBI->connect('dbi:AnyData(RaiseError=>1):');
39    
40     my $data = $self->sponge->{rows};
41     unshift @$data, $self->sponge->{NAME};
42    
43     warn "# data = ",dump( $data );
44    
45     $dbh->func( $self->table, 'ARRAY', $data, 'ad_import' );
46    
47     return $dbh->selectall_arrayref( $self->query );
48     }
49    
50     1;

  ViewVC Help
Powered by ViewVC 1.1.26