From 76b830036ae0f32199c10c3285dfbf8853043b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Wed, 20 Aug 2014 21:19:34 +0200 Subject: [PATCH] fix sql syntax for pgsql --- lib/bookmarks.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/bookmarks.php b/lib/bookmarks.php index 1b8d2478..e843b1f9 100644 --- a/lib/bookmarks.php +++ b/lib/bookmarks.php @@ -377,9 +377,15 @@ class OC_Bookmarks_Bookmarks{ * @return null **/ private static function addTags($bookmarkId, $tags) { - $query = OCP\DB::prepare("INSERT INTO `*PREFIX*bookmarks_tags` (`bookmark_id`, `tag`) - select ?, ? where not exists(select * from oc_bookmarks_tags where bookmark_id = ? and tag = ?)"); + $sql = 'INSERT INTO `*PREFIX*bookmarks_tags` (`bookmark_id`, `tag`) select ?, ? '; + $dbtype = OCP\Config::getSystemValue( 'dbtype', 'sqlite' ); + if ($dbtype === 'mysql') { + $sql .= 'from dual '; + } + $sql .= 'where not exists(select * from oc_bookmarks_tags where bookmark_id = ? and tag = ?)'; + + $query = OCP\DB::prepare($sql); foreach ($tags as $tag) { $tag = trim($tag); if(empty($tag)) {