MDL-52707 tags: fix SQL query to work on all DBs

This commit is contained in:
Marina Glancy 2016-04-13 07:46:44 +08:00
parent aca13ea2b6
commit f40b444ef8

View file

@ -1583,10 +1583,10 @@ class core_tag_tag {
// Item is tagged with both main tag and the duplicate tag. // Item is tagged with both main tag and the duplicate tag.
// Remove instance pointing to the duplicate tag. // Remove instance pointing to the duplicate tag.
$tag->delete_instance_as_record($record, false); $tag->delete_instance_as_record($record, false);
$sql = "UPDATE {tag_instance} ti SET ordering = ordering - 1 $sql = "UPDATE {tag_instance} SET ordering = ordering - 1
WHERE ti.itemtype = :itemtype WHERE itemtype = :itemtype
AND ti.itemid = :itemid AND ti.component = :component AND ti.tiuserid = :tiuserid AND itemid = :itemid AND component = :component AND tiuserid = :tiuserid
AND ti.ordering > :ordering"; AND ordering > :ordering";
$DB->execute($sql, (array)$record); $DB->execute($sql, (array)$record);
} else { } else {
// Item is tagged only with duplicate tag but not the main tag. // Item is tagged only with duplicate tag but not the main tag.