From 6973ac45c1f9735df2a86754b6cd6ae9861f39d8 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 3 Jul 2019 09:57:16 +0200 Subject: [exams] Fix creating global exam --- install.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'install.php') diff --git a/install.php b/install.php index 5f5fe369..38cc3a1e 100644 --- a/install.php +++ b/install.php @@ -154,7 +154,7 @@ function tableGetConstraints($table, $column, $refTable, $refColumn) * @param string $actions "ON xxx ON yyy" string * @return string UPDATE_* result code */ -function tableAddConstraint($table, $column, $refTable, $refColumn, $actions, $ignoreError = false) +function tableAddConstraint($table, $column, $refTable, $refColumn, $actions, $ignoreError = false, $name = '') { $test = tableExists($refTable) && tableHasColumn($refTable, $refColumn); if ($test === false) { @@ -194,7 +194,10 @@ function tableAddConstraint($table, $column, $refTable, $refColumn, $actions, $i WHERE `$refTable`.`$refColumn` IS NULL"); } // Need to create - $ret = Database::exec("ALTER TABLE `$table` ADD CONSTRAINT FOREIGN KEY (`$column`) + if (!empty($name)) { + $name = "`$name`"; + } + $ret = Database::exec("ALTER TABLE `$table` ADD CONSTRAINT $name FOREIGN KEY (`$column`) REFERENCES `$refTable` (`$refColumn`) ON DELETE $delete ON UPDATE $update"); if ($ret === false) { -- cgit v1.2.3-55-g7522