From 757ec2dbc109939684de1f5b30adacfcf3ab50c3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 1 Apr 2021 09:27:20 -0400 Subject: [PATCH] Improve zmDbDo to return rows affected instead of boolean --- scripts/ZoneMinder/lib/ZoneMinder/Database.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Database.pm b/scripts/ZoneMinder/lib/ZoneMinder/Database.pm index 3fdcab5e2..18df301f3 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Database.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Database.pm @@ -266,15 +266,14 @@ sub end_transaction { } # end sub end_transaction # Basic execution of $dbh->do but with some pretty logging of the sql on error. -# Returns 1 on success, 0 on error sub zmDbDo { my $sql = shift; - if ( ! $dbh->do($sql, undef, @_) ) { + my $rows = $dbh->do($sql, undef, @_); + if ( ! defined $rows ) { $sql =~ s/\?/'%s'/; Error(sprintf("Failed $sql :", @_).$dbh->errstr()); - return 0; } - return 1; + return $rows; } 1;