Improve zmDbDo to return rows affected instead of boolean

pull/3208/head
Isaac Connor 2021-04-01 09:27:20 -04:00
parent 9f5bc8b2b9
commit 757ec2dbc1
1 changed files with 3 additions and 4 deletions

View File

@ -266,15 +266,14 @@ sub end_transaction {
} # end sub end_transaction } # end sub end_transaction
# Basic execution of $dbh->do but with some pretty logging of the sql on error. # Basic execution of $dbh->do but with some pretty logging of the sql on error.
# Returns 1 on success, 0 on error
sub zmDbDo { sub zmDbDo {
my $sql = shift; my $sql = shift;
if ( ! $dbh->do($sql, undef, @_) ) { my $rows = $dbh->do($sql, undef, @_);
if ( ! defined $rows ) {
$sql =~ s/\?/'%s'/; $sql =~ s/\?/'%s'/;
Error(sprintf("Failed $sql :", @_).$dbh->errstr()); Error(sprintf("Failed $sql :", @_).$dbh->errstr());
return 0;
} }
return 1; return $rows;
} }
1; 1;