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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26