/[Frey]/trunk/lib/Frey/DBI.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/DBI.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 932 - (hide annotations)
Tue Jan 6 00:21:29 2009 UTC (15 years, 4 months ago) by dpavlin
File size: 645 byte(s)
spunge tweaks
1 dpavlin 366 package Frey::DBI;
2     use Moose;
3    
4     extends 'Frey';
5    
6     use DBI;
7    
8     has 'dsn' => (
9     is => 'ro',
10     isa => 'dsn',
11     default => 'DBI:Pg:dbname=template1',
12     required => 1,
13     );
14    
15     has 'query' => (
16     is => 'ro',
17     isa => 'Str',
18     required => 1,
19     default => 'select 42 as meaning_of_life',
20     );
21    
22 dpavlin 455 sub as_sponge {
23 dpavlin 366 my ( $self ) = @_;
24    
25 dpavlin 885 warn "# dsn: ", $self->dsn;
26 dpavlin 366 my $dbh = DBI->connect( $self->dsn, '', '', { RaiseError => 1 } ) || die $DBI::errstr;
27     $dbh->do( qq{ set client_encoding='utf-8' } );
28    
29 dpavlin 885 warn "# query: ", $self->query;
30 dpavlin 366 my $sth = $dbh->prepare( $self->query );
31     $sth->execute();
32    
33     return {
34     NAME => $sth->{NAME},
35     rows => $sth->fetchall_arrayref,
36     };
37     }
38    
39     1;

  ViewVC Help
Powered by ViewVC 1.1.26