From 649907a529ae4bee21990c05f196a144dab8624b Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Thu, 23 Feb 2017 07:40:49 +0100 Subject: [PATCH] use transaction method instead of direct BEGIN/COMMIT/ROLLBACK queries --- web/briskin5/stat-day.php | 17 ++++++++++------- web/briskin5/statadm.php | 6 +++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/web/briskin5/stat-day.php b/web/briskin5/stat-day.php index cadeb26..a9fcdee 100644 --- a/web/briskin5/stat-day.php +++ b/web/briskin5/stat-day.php @@ -258,10 +258,10 @@ function main_pgsql($from, $to) break; } - if (pg_query($bdb->dbconn->db(), "BEGIN") == FALSE) { - log_crit("stat-day: begin failed"); - break; - } + //if ($bdb->transaction("BEGIN") == FALSE) { + // log_crit("stat-day: begin failed"); + // break; + //} // retrieve list of active tournaments $trn_sql = sprintf("SELECT * FROM %sbin5_tournaments WHERE active = 1;", $G_dbpfx); @@ -482,12 +482,15 @@ SELECT sum(p.pts * (2^g.mult)) AS pts log_crit(sprintf("stat-day: t < trn_n (%d, %d)", $t, $trn_n)); break; } + // if ($bdb->transaction("COMMIT") == FALSE) { + // break; + // } $ret = (TRUE); } while (0); - if ($ret == FALSE) { - pg_query($bdb->dbconn->db(), "ROLLBACK"); - } + // if ($ret == FALSE) { + // $bdb->transaction("ROLLBACK"); + // } if ($fpexp != FALSE) { fclose($fpexp); } diff --git a/web/briskin5/statadm.php b/web/briskin5/statadm.php index ee06e08..e88a9f9 100644 --- a/web/briskin5/statadm.php +++ b/web/briskin5/statadm.php @@ -225,7 +225,7 @@ function main_pgsql($curtime) $maxg = array( TRI_MAX_GAMES, MON_MAX_GAMES, WEE_MAX_GAMES ); do { - if (pg_query($bdb->dbconn->db(), "BEGIN") == FALSE) { + if ($bdb->transaction("BEGIN") == FALSE) { log_crit("statadm: begin failed"); break; } @@ -400,13 +400,13 @@ function main_pgsql($curtime) break; } - if (pg_query($bdb->dbconn->db(), "COMMIT") == FALSE) { + if ($bdb->transaction("COMMIT") == FALSE) { break; } return (TRUE); } while (0); - pg_query($bdb->dbconn->db(), "ROLLBACK"); + $bdb->transaction("ROLLBACK"); return (FALSE); } -- 2.17.1