From 4721be5c68b2a9c665a76619d834dee6cf2d40ef Mon Sep 17 00:00:00 2001 From: Erik Ordway Date: Wed, 7 Sep 2011 12:08:33 -0700 Subject: [PATCH] make sql more generic to work on postgresql Using multiple table as x in the first section of an UPDATE is specific to mysql "UPDATE {attendance_statuses} AS sta,{attforblock} AS att SET sta.attendanceid=att.id WHERE att.course=sta.courseid"; is now "UPDATE {attendance_statuses} SET attendanceid={attforblock}.id FROM {attforblock} WHERE {attforblock}.course=courseid"; --- db/upgrade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index edb4e59..918cd8a 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -257,7 +257,7 @@ function xmldb_attforblock_upgrade($oldversion=0) { $dbman->add_index($table, $index); } - $sql = "UPDATE {attendance_sessions} AS ses,{attforblock} AS att SET ses.attendanceid=att.id WHERE att.course=ses.courseid"; + $sql = "UPDATE {attendance_sessions} SET attendanceid={attforblock}.id FROM {attforblock} WHERE {attforblock}.course=courseid"; $DB->execute($sql); $table = new xmldb_table('attendance_statuses'); @@ -273,7 +273,7 @@ function xmldb_attforblock_upgrade($oldversion=0) { $dbman->add_index($table, $index); } - $sql = "UPDATE {attendance_statuses} AS sta,{attforblock} AS att SET sta.attendanceid=att.id WHERE att.course=sta.courseid"; + $sql = "UPDATE {attendance_statuses} SET attendanceid={attforblock}.id FROM {attforblock} WHERE {attforblock}.course=courseid"; $DB->execute($sql); upgrade_mod_savepoint(true, 2010123003, 'attforblock');