summaryrefslogtreecommitdiffstatshomepage
path: root/src/SemanticScuttle/Service/Bookmark2Tag.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/SemanticScuttle/Service/Bookmark2Tag.php')
-rw-r--r--src/SemanticScuttle/Service/Bookmark2Tag.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark2Tag.php b/src/SemanticScuttle/Service/Bookmark2Tag.php
index 910da48..232fc80 100644
--- a/src/SemanticScuttle/Service/Bookmark2Tag.php
+++ b/src/SemanticScuttle/Service/Bookmark2Tag.php
@@ -208,7 +208,16 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
return false;
}
}
- $this->db->sql_transaction('commit');
+
+ if ($this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit attaching tags',
+ '', __LINE__, __FILE__, $sql, $this->db
+ );
+ return false;
+ }
+
return true;
}
@@ -287,7 +296,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$query = 'SELECT tag FROM ' . $this->getTableName()
. ' WHERE bId = ' . intval($bookmarkid);
if (!$systemTags) {
- $query .= ' AND LEFT(tag, 7) <> "system:"';
+ $query .= ' AND ' . $this->db->QueryBuilder->left('tag', 7) . ' <> "system:"';
}
$query .= ' ORDER BY id ASC';
@@ -329,7 +338,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$query = 'SELECT tag, bId FROM ' . $this->getTableName()
. ' WHERE bId IN (' . implode(',', $bookmarkids) . ')'
- . ' AND LEFT(tag, 7) <> "system:"'
+ . ' AND ' . $this->db->QueryBuilder->left('tag', 7) . ' <> "system:"'
. ' ORDER BY id, bId ASC';
if (!($dbresult = $this->db->sql_query($query))) {
@@ -367,7 +376,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$conditions['B.bStatus'] = 0;
}
- $query .= ' WHERE '. $this->db->sql_build_array('SELECT', $conditions) .' AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC, tag';
+ $query .= ' WHERE '. $this->db->sql_build_array('SELECT', $conditions) .' AND ' . $this->db->QueryBuilder->left('T.tag', 7) . ' <> "system:" GROUP BY T.tag ORDER BY bCount DESC, tag';
if (!($dbresult = $this->db->sql_query($query))) {
message_die(GENERAL_ERROR, 'Could not get tags', '', __LINE__, __FILE__, $query, $this->db);
@@ -414,7 +423,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$query_2 .= ', '. $this->getTableName() .' AS T'. $i;
$query_4 .= ' AND T'. $i .'.bId = B.bId AND T'. $i .'.tag = "'. $this->db->sql_escape($tags[$i - 1]) .'" AND T0.tag <> "'. $this->db->sql_escape($tags[$i - 1]) .'"';
}
- $query_5 = ' AND LEFT(T0.tag, 7) <> "system:" GROUP BY T0.tag ORDER BY bCount DESC, T0.tag';
+ $query_5 = ' AND ' . $this->db->QueryBuilder->left('T0.tag', 7) . ' <> "system:" GROUP BY T0.tag ORDER BY bCount DESC, T0.tag';
$query = $query_1 . $query_2 . $query_3 . $query_4 . $query_5;
if (! ($dbresult = $this->db->sql_query_limit($query, $limit)) ){
@@ -445,7 +454,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
$privacy = ' AND B.bStatus = 0 ';
}
- $query = 'SELECT T.tag, COUNT(T.tag) AS bCount FROM '.$GLOBALS['tableprefix'].'bookmarks AS B LEFT JOIN '.$GLOBALS['tableprefix'].'bookmarks2tags AS T ON B.bId = T.bId WHERE B.bHash = \''. $this->db->sql_escape($hash) .'\' '. $privacy .'AND LEFT(T.tag, 7) <> "system:" GROUP BY T.tag ORDER BY bCount DESC';
+ $query = 'SELECT T.tag, COUNT(T.tag) AS bCount FROM '.$GLOBALS['tableprefix'].'bookmarks AS B LEFT JOIN '.$GLOBALS['tableprefix'].'bookmarks2tags AS T ON B.bId = T.bId WHERE B.bHash = \''. $this->db->sql_escape($hash) .'\' '. $privacy .'AND ' . $this->db->QueryBuilder->left('T.tag', 7) . ' <> "system:" GROUP BY T.tag ORDER BY bCount DESC';
if (!($dbresult = $this->db->sql_query_limit($query, $limit))) {
message_die(GENERAL_ERROR, 'Could not get related tags for this hash', '', __LINE__, __FILE__, $query, $this->db);
@@ -599,7 +608,7 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
. '%\'';
}
- $query .= ' AND LEFT(T.tag, 7) <> "system:"'
+ $query .= ' AND ' . $this->db->QueryBuilder->left('T.tag', 7) . ' <> "system:"'
. ' GROUP BY T.tag'
. ' ORDER BY bCount DESC, tag';