/[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 374 by dpavlin, Mon Nov 17 15:42:41 2008 UTC revision 926 by dpavlin, Mon Jan 5 22:10:59 2009 UTC
# Line 1  Line 1 
1  package Frey::SQL;  package Frey::SQL;
2  use Moose;  use Moose;
3    extends 'Frey';
4    
5  use MooseX::Types::Moose qw(Str Int ArrayRef);  with 'Frey::Web';
 use MooseX::Types::Structured qw/Dict/;  
6    
7  use DBI;  use DBI;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9    
10    has 'sponge' => (
11            is => 'rw',
12            isa => 'Sponge',
13            required => 1,
14    );
15    
16  has 'query' => (  has 'query' => (
17          is => 'rw',          is => 'rw',
18          isa => 'Str',          isa => 'Str',
# Line 23  has table => ( Line 29  has table => (
29          documentation => 'Name of table to create from sponge data',          documentation => 'Name of table to create from sponge data',
30  );  );
31    
32  has 'sponge' => (  sub as_data {
         is => 'rw',  
         isa => Dict[  
                 rows => ArrayRef[ArrayRef],  
                 NAME => ArrayRef[Str],  
         ],  
         required => 1,  
 );  
   
 sub data {  
33          my ($self) = @_;          my ($self) = @_;
34    
35          my $dbh=DBI->connect('dbi:AnyData(RaiseError=>1):');          my $dbh=DBI->connect('dbi:AnyData(RaiseError=>1):');
# Line 40  sub data { Line 37  sub data {
37          my $data = $self->sponge->{rows};          my $data = $self->sponge->{rows};
38          unshift @$data, $self->sponge->{NAME};          unshift @$data, $self->sponge->{NAME};
39    
40          warn "# data = ",dump( $data );          warn "# data = ",dump( $data ) if $self->debug;
41    
42          $dbh->func( $self->table, 'ARRAY', $data, 'ad_import' );          $dbh->func( $self->table, 'ARRAY', $data, 'ad_import' );
43    

Legend:
Removed from v.374  
changed lines
  Added in v.926

  ViewVC Help
Powered by ViewVC 1.1.26