From c949a9282e1102e82cca5bb158e84f742e8f1456 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 2 Dec 2017 01:08:30 +0300 Subject: OPML: use PDO; minor fixes --- classes/labels.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'classes/labels.php') diff --git a/classes/labels.php b/classes/labels.php index 9c6f22f51..973732b99 100644 --- a/classes/labels.php +++ b/classes/labels.php @@ -131,8 +131,13 @@ class Labels if (!$owner_uid) $owner_uid = $_SESSION["uid"]; $pdo = Db::pdo(); + $tr_in_progress = false; - $pdo->beginTransaction(); + try { + $pdo->beginTransaction(); + } catch (Exception $e) { + $tr_in_progress = true; + } $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 WHERE id = ?"); @@ -163,7 +168,7 @@ class Labels } - $pdo->commit(); + if (!$tr_in_progress) $pdo->commit(); } static function create($caption, $fg_color = '', $bg_color = '', $owner_uid = false) { @@ -172,7 +177,13 @@ class Labels $pdo = Db::pdo(); - $pdo->beginTransaction(); + $tr_in_progress = false; + + try { + $pdo->beginTransaction(); + } catch (Exception $e) { + $tr_in_progress = true; + } $sth = $pdo->prepare("SELECT id FROM ttrss_labels2 WHERE caption = ? AND owner_uid = ?"); @@ -187,7 +198,7 @@ class Labels $result = $sth->rowCount(); } - $pdo->commit(); + if (!$tr_in_progress) $pdo->commit(); return $result; } -- cgit v1.2.3-54-g00ecf