/[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 885 - (hide annotations)
Wed Dec 24 13:49:55 2008 UTC (15 years, 4 months ago) by dpavlin
File size: 743 byte(s)
dump some debug using warn
1 dpavlin 366 package Frey::DBI;
2     use Moose;
3    
4     extends 'Frey';
5    
6     use DBI;
7     use Moose::Util::TypeConstraints;
8    
9     subtype 'dsn'
10     => as 'Str'
11     => where {
12     DBI->parse_dsn( $_ );
13     };
14    
15     has 'dsn' => (
16     is => 'ro',
17     isa => 'dsn',
18     default => 'DBI:Pg:dbname=template1',
19     required => 1,
20     );
21    
22     has 'query' => (
23     is => 'ro',
24     isa => 'Str',
25     required => 1,
26     default => 'select 42 as meaning_of_life',
27     );
28    
29 dpavlin 455 sub as_sponge {
30 dpavlin 366 my ( $self ) = @_;
31    
32 dpavlin 885 warn "# dsn: ", $self->dsn;
33 dpavlin 366 my $dbh = DBI->connect( $self->dsn, '', '', { RaiseError => 1 } ) || die $DBI::errstr;
34     $dbh->do( qq{ set client_encoding='utf-8' } );
35    
36 dpavlin 885 warn "# query: ", $self->query;
37 dpavlin 366 my $sth = $dbh->prepare( $self->query );
38     $sth->execute();
39    
40     return {
41     NAME => $sth->{NAME},
42     rows => $sth->fetchall_arrayref,
43     };
44     }
45    
46     1;

  ViewVC Help
Powered by ViewVC 1.1.26