From: Janusz Dobrowolski Date: Sun, 25 Oct 2009 12:27:15 +0000 (+0000) Subject: Fixed compatibility issue with MySQL 3.xx X-Git-Tag: v2.4.2~19^2~1073 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=e3fc2f978c2726ecf1ecd2ab8f82acf92c931393;p=fa-stable.git Fixed compatibility issue with MySQL 3.xx --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b47f5e1a..fc97f271 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 diff --git a/admin/db/tags_db.inc b/admin/db/tags_db.inc index 2e7ac061..6b6aec4d 100644 --- a/admin/db/tags_db.inc +++ b/admin/db/tags_db.inc @@ -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"); + } } //--------------------------------------------------------------------------------------