From: toyomoyo Date: Mon, 19 Nov 2007 01:13:31 +0000 (+0000) Subject: making a SQL cross-db compatible X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f7bd8c758f08d9ac68db6dc469764a0573206921;p=moodle.git making a SQL cross-db compatible --- diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 891e5019f7..d2bca4b253 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2589,7 +2589,7 @@ function xmldb_main_upgrade($oldversion=0) { /// try to remove duplicate entries - $SQL = "SELECT id, userid, itemid + $SQL = "SELECT userid, itemid, COUNT(*) FROM {$CFG->prefix}grade_grades GROUP BY userid, itemid HAVING COUNT( * ) >1"; @@ -2597,7 +2597,7 @@ function xmldb_main_upgrade($oldversion=0) { if ($dups = get_records_sql($SQL)) { // for each set of userid, itemid foreach ($dups as $dup) { - if ($thisdups = get_records_sql("SELECT id,id FROM {$CFG->prefix}grade_grades + if ($thisdups = get_records_sql("SELECT id FROM {$CFG->prefix}grade_grades WHERE itemid = $dup->itemid AND userid = $dup->userid ORDER BY timemodified DESC")) {