/[A3C]/lib/A3C/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 /lib/A3C/SQL.pm

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

revision 82 by dpavlin, Sat Apr 12 10:28:38 2008 UTC revision 145 by dpavlin, Sat May 31 16:30:09 2008 UTC
# Line 3  package A3C::SQL; Line 3  package A3C::SQL;
3  use strict;  use strict;
4  use warnings;  use warnings;
5    
6    use base qw(Jifty::Object Class::Accessor::Fast);
7    __PACKAGE__->mk_accessors( qw(query arguments dbh) );
8    
9    use Data::Dump qw/dump/;
10    
11  =head1 NAME  =head1 NAME
12    
13  A3C::SQL  A3C::SQL
# Line 17  Issue SQL queries Line 22  Issue SQL queries
22    
23    my $sql = A3C::SQL->new({ query => 'select now()' });    my $sql = A3C::SQL->new({ query => 'select now()' });
24    
25  =cut  As a alternative, if you don't want to use Jifty's database handle,
26    specify it like this:
 use base qw(Jifty::Object Class::Accessor::Fast);  
 __PACKAGE__->mk_accessors( qw(query arguments) );  
27    
28  use Data::Dump qw/dump/;    my $sql = A3C::SQL->new({
29            query => 'select now()',
30            dbh => $my_dbh,
31      });
32    
33  =head2 sth  =head2 sth
34    
# Line 33  Execute query and return statement handl Line 39  Execute query and return statement handl
39  sub sth {  sub sth {
40          my $self = shift;          my $self = shift;
41          if ( ! $self->{_sth} ) {          if ( ! $self->{_sth} ) {
42                  my $dbh = Jifty->handle->dbh;                  my $dbh = $self->dbh || Jifty->handle->dbh;
43                  my $sth = $dbh->prepare( $self->query ) or $dbh->errstr;                  my $sth = $dbh->prepare( $self->query ) or $dbh->errstr;
44                  if ( $self->arguments ) {                  if ( $self->arguments ) {
45                          Jifty->log->debug( $self->sql . ' arguments: ' . dump( $self->arguments ) );                          Jifty->log->debug( $self->sql . ' arguments: ' . dump( $self->arguments ) );

Legend:
Removed from v.82  
changed lines
  Added in v.145

  ViewVC Help
Powered by ViewVC 1.1.26