X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=dd8cc542c803ec30f4396c73b5e24827f5331dd8;hp=18541d2db7aca8de3d7e88d68f1f7f05d0cb8d71;hb=d220c8a4bfa1aee8f17ed71c2dba655160dd3595;hpb=b90f8cdac9371c219a72dda16f8deecc7c44fc28 diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 18541d2db..dd8cc542c 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -176,7 +176,7 @@ sub qsearch { my $statement = "SELECT $select FROM $table"; if ( @fields ) { - $statement .= " WHERE ". join(' AND ', map { + $statement .= ' WHERE '. join(' AND ', map { if ( ! defined( $record->{$_} ) || $record->{$_} eq '' ) { if ( driver_name eq 'Pg' ) { "$_ IS NULL"; @@ -191,11 +191,13 @@ sub qsearch { $statement .= " $extra_sql" if defined($extra_sql); warn $statement if $DEBUG; - my $sth = $dbh->prepare_cached($statement) or croak $dbh->errstr; + my $sth = $dbh->prepare_cached($statement) + or croak "$dbh->errstr doing $statement"; $sth->execute( map $record->{$_}, grep defined( $record->{$_} ) && $record->{$_} ne '', @fields ) or croak $dbh->errstr; + $dbh->commit or croak $dbh->errstr if $FS::UID::AutoCommit; if ( eval 'scalar(@FS::'. $table. '::ISA);' ) { if ( eval 'FS::'. $table. '->can(\'new\')' eq \&new ) { @@ -387,6 +389,7 @@ sub insert { local $SIG{PIPE} = 'IGNORE'; $sth->execute or return $sth->errstr; + dbh->commit or croak dbh->errstr if $FS::UID::AutoCommit; ''; } @@ -436,6 +439,7 @@ sub delete { my $rc = $sth->execute or return $sth->errstr; #not portable #return "Record not found, statement:\n$statement" if $rc eq "0E0"; + dbh->commit or croak dbh->errstr if $FS::UID::AutoCommit; undef $self; #no need to keep object! @@ -507,6 +511,7 @@ sub replace { my $rc = $sth->execute or return $sth->errstr; #not portable #return "Record not found (or records identical)." if $rc eq "0E0"; + dbh->commit or croak dbh->errstr if $FS::UID::AutoCommit; ''; @@ -891,6 +896,8 @@ sub hfields { # } (fields($self->table)) ); #} +sub DESTROY { return; } + #sub DESTROY { # my $self = shift; # #use Carp qw(cluck); @@ -906,7 +913,7 @@ sub hfields { =head1 VERSION -$Id: Record.pm,v 1.10 2000-12-03 20:25:20 ivan Exp $ +$Id: Record.pm,v 1.12 2001-02-03 14:03:49 ivan Exp $ =head1 BUGS