/[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 145 by dpavlin, Sat May 31 16:30:09 2008 UTC revision 160 by dpavlin, Sun Jun 15 16:10:13 2008 UTC
# Line 43  sub sth { Line 43  sub sth {
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 ) );
46                          $sth->execute( $self->arguments ) or $dbh->errstr;                          $sth->execute( $self->arguments ) or die $dbh->errstr;
47                  } else {                  } else {
48                          $sth->execute or $dbh->errstr;                          $sth->execute or die $dbh->errstr;
49                  }                  }
50                  $self->{_sth} = $sth;                  $self->{_sth} = $sth;
51          }          }
# Line 79  sub count { Line 79  sub count {
79          return $self->sth->rows;          return $self->sth->rows;
80  }  }
81    
82    =head1 HELPERS
83    
84    This helpers are accessor to L<DBI>
85    
86    =head2 _column_names
87    
88      my @columns = $sql->_column_names;
89    
90    =cut
91    
92    sub _column_names {
93            my $self = shift;
94            return @{ $self->sth->{NAME} };
95    }
96    
97  package A3C::SQL::row;  package A3C::SQL::row;
98    
99  use Encode qw/decode/;  use Encode qw/decode/;
100  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
101    use base qw/Jifty::Object/;
102    
103  our $AUTOLOAD;  our $AUTOLOAD;
104    
# Line 99  sub AUTOLOAD { Line 115  sub AUTOLOAD {
115          my $type = ref($self) or die "$self is not an object";          my $type = ref($self) or die "$self is not an object";
116          my $name = $AUTOLOAD;          my $name = $AUTOLOAD;
117          $name =~ s/.*://;          $name =~ s/.*://;
118  #       warn "SQL: $name doesn't exist" unless defined($self->{$name});          Jifty->log->error("SQL: $name doesn't exist") unless defined($self->{$name});
119          return decode('UTF-8', $self->{$name});          return decode('UTF-8', $self->{$name});
120  }  }
121    

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

  ViewVC Help
Powered by ViewVC 1.1.26