4 |
use warnings; |
use warnings; |
5 |
|
|
6 |
use base qw(Jifty::Object Class::Accessor::Fast); |
use base qw(Jifty::Object Class::Accessor::Fast); |
7 |
__PACKAGE__->mk_accessors( qw(query arguments dbh) ); |
__PACKAGE__->mk_accessors( qw(query arguments dbh encoding) ); |
8 |
|
|
9 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
10 |
|
|
28 |
my $sql = A3C::SQL->new({ |
my $sql = A3C::SQL->new({ |
29 |
query => 'select now()', |
query => 'select now()', |
30 |
dbh => $my_dbh, |
dbh => $my_dbh, |
31 |
|
encoding => 'UTF-8', |
32 |
}); |
}); |
33 |
|
|
34 |
=head2 sth |
=head2 sth |
66 |
my $self = shift; |
my $self = shift; |
67 |
my $row = $self->sth->fetchrow_hashref; |
my $row = $self->sth->fetchrow_hashref; |
68 |
return unless defined $row; |
return unless defined $row; |
69 |
return A3C::SQL::row->new( $row ); |
return A3C::SQL::row->new( $row, $self->encoding ); |
70 |
} |
} |
71 |
|
|
72 |
=head2 count |
=head2 count |
108 |
my $class = ref($that) || $that; |
my $class = ref($that) || $that; |
109 |
my $self = shift; |
my $self = shift; |
110 |
bless $self, $class; |
bless $self, $class; |
111 |
|
$self->{__encoding} = shift || 'UTF-8'; |
112 |
return $self; |
return $self; |
113 |
} |
} |
114 |
|
|
118 |
my $name = $AUTOLOAD; |
my $name = $AUTOLOAD; |
119 |
$name =~ s/.*://; |
$name =~ s/.*://; |
120 |
Jifty->log->error("SQL: $name doesn't exist") unless defined($self->{$name}); |
Jifty->log->error("SQL: $name doesn't exist") unless defined($self->{$name}); |
121 |
return decode('UTF-8', $self->{$name}); |
return decode( $self->{__encoding}, $self->{$name} ); |
122 |
} |
} |
123 |
|
|
124 |
sub DESTROY {} |
sub DESTROY {} |