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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 370 by dpavlin, Mon Nov 17 15:14:07 2008 UTC revision 455 by dpavlin, Wed Nov 19 15:28:23 2008 UTC
# Line 1  Line 1 
1  package Frey::SQL;  package Frey::SQL;
2  use Moose;  use Moose;
3    extends 'Frey';
4    
5    with 'Frey::Web';
6    
7  use MooseX::Types::Moose qw(Str Int ArrayRef);  use MooseX::Types::Moose qw(Str Int ArrayRef);
8  use MooseX::Types::Structured qw/Dict/;  use MooseX::Types::Structured qw/Dict/;
# Line 11  has 'query' => ( Line 14  has 'query' => (
14          is => 'rw',          is => 'rw',
15          isa => 'Str',          isa => 'Str',
16          required => 1,          required => 1,
17          default => sub {          default => 'select * from sponge',
18                  my ($self) = @_;          documentation => 'SQL query to filter data',
                 'select * from ' . $self->table;  
         },  
19  );  );
20    
21  has table => (  has table => (
# Line 22  has table => ( Line 23  has table => (
23          isa => 'Str',          isa => 'Str',
24          required => 1,          required => 1,
25          default => 'sponge',          default => 'sponge',
26            documentation => 'Name of table to create from sponge data',
27  );  );
28    
29  has 'sponge' => (  has 'sponge' => (
# Line 33  has 'sponge' => ( Line 35  has 'sponge' => (
35          required => 1,          required => 1,
36  );  );
37    
38  sub data {  sub as_data {
39          my ($self) = @_;          my ($self) = @_;
40    
41          my $dbh=DBI->connect('dbi:AnyData(RaiseError=>1):');          my $dbh=DBI->connect('dbi:AnyData(RaiseError=>1):');
42    
43            my $data = $self->as_sponge->{rows};
44            unshift @$data, $self->as_sponge->{NAME};
45    
46            warn "# data = ",dump( $data ) if $self->debug;
         my $data = $self->sponge->{rows};  
         unshift @$data, $self->sponge->{NAME};  
   
         warn "# data = ",dump( $data );  
47    
48          $dbh->func( $self->table, 'ARRAY', $data, 'ad_import' );          $dbh->func( $self->table, 'ARRAY', $data, 'ad_import' );
49    

Legend:
Removed from v.370  
changed lines
  Added in v.455

  ViewVC Help
Powered by ViewVC 1.1.26