Fixed compatibility issue with MySQL 3.xx
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 25 Oct 2009 12:27:15 +0000 (12:27 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 25 Oct 2009 12:27:15 +0000 (12:27 +0000)
CHANGELOG.txt
admin/db/tags_db.inc

index b47f5e1a97b534efe2a0982e4b42551ce72e9727..fc97f27159dcafc83e1cb609a991611ef927333a 100644 (file)
@@ -19,6 +19,10 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+24-Oct-2009 Janusz Dobrowolski
+# Fixed compatibility issue with MySQL 3.xx
+$ /admin/db/tags_db.inc
+
 24-Oct-2009 Janusz Dobrowolski
 + Default add/update button, ajax update.
 $ /dimensions/dimension_entry.php
index 2e7ac061b4af47d89a5fd4340ad14c43702fae07..6b6aec4d60436d35f5e1311a9b2085051a66c1bf 100644 (file)
@@ -125,19 +125,29 @@ function update_tag_associations($type, $recordid, $tagids)
 }
 
 //--------------------------------------------------------------------------------------
-
 // To delete tag associations, we need to specify the tag type.
 // Otherwise we may inadvertantly delete records for another type of tag
+//
 function delete_tag_associations($type, $recordid, $all=false)
 {
-       $sql = "DELETE ta FROM ".TB_PREF."tag_associations AS ta 
-                               INNER JOIN ".TB_PREF."tags AS tags ON tags.id = ta.tag_id 
+/* multiply table DELETE syntax available since MySQL 4.0.0:
+       $sql = "DELETE ta FROM ".TB_PREF."tag_associations ta 
+                               INNER JOIN ".TB_PREF."tags tags ON tags.id = ta.tag_id 
                                WHERE tags.type = ".db_escape($type)." AND ta.record_id = ".db_escape($recordid);
-       
+*/
+       // To support MySQL 3.xx we have to use multiply queries
+       $sql = "SELECT * FROM ".TB_PREF."tag_associations ta 
+                       INNER JOIN ".TB_PREF."tags tags ON tags.id = ta.tag_id 
+                       WHERE tags.type = ".db_escape($type)." AND ta.record_id = ".db_escape($recordid);
        if (!$all)
                $sql .= " AND tags.inactive = 0";
+       $result = db_query($sql, "could not select tag associations");
 
-       db_query($sql, "could not delete tag associations");
+       while($ta = db_fetch($result)) {
+               $sql2 = "DELETE FROM ".TB_PREF."tag_associations WHERE 
+                       record_id = '".$ta['record_id']."' AND tag_id=".$ta['tag_id'];
+               db_query($sql2, "could not delete tag associations");
+       }
 }
 
 //--------------------------------------------------------------------------------------