1
0
mirror of https://github.com/owncloud/bookmarks.git synced 2025-01-18 14:52:10 +01:00

fix duplicate insert

This commit is contained in:
Thomas Müller 2014-08-20 15:26:02 +02:00
parent 01b977e6ae
commit bd70de98ae

View File

@ -371,22 +371,22 @@ class OC_Bookmarks_Bookmarks{
/**
* Add a set of tags for a bookmark
* @param int $bookmark_id The bookmark reference
*
* @param int $bookmarkId The bookmark reference
* @param array $tags Set of tags to add to the bookmark
* @return null
**/
private static function addTags($bookmark_id, $tags) {
$query = OCP\DB::prepare("
INSERT INTO `*PREFIX*bookmarks_tags`
(`bookmark_id`, `tag`)
VALUES (?, ?)");
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 = ?)");
foreach ($tags as $tag) {
$tag = trim($tag);
if(empty($tag)) {
//avoid saving blankspaces
//avoid saving white spaces
continue;
}
$params = array($bookmark_id, trim($tag));
$params = array($bookmarkId, $tag, $bookmarkId, $tag);
$query->execute($params);
}
}