summaryrefslogtreecommitdiff
path: root/classes/labels.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-12-02 01:08:30 +0300
committerAndrew Dolgov <[email protected]>2017-12-02 01:08:30 +0300
commitc949a9282e1102e82cca5bb158e84f742e8f1456 (patch)
tree2f9ad4bd1cd8ed3c365aa3e2b449a9fec036ca62 /classes/labels.php
parent4102eb843ff11a4aae0cc890cf700b7e3b4e72e2 (diff)
OPML: use PDO; minor fixes
Diffstat (limited to 'classes/labels.php')
-rw-r--r--classes/labels.php19
1 files changed, 15 insertions, 4 deletions
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;
}