summaryrefslogtreecommitdiffstats
path: root/install.php
diff options
context:
space:
mode:
authorSimon Rettberg2019-07-03 09:57:16 +0200
committerSimon Rettberg2019-07-03 09:57:16 +0200
commita867108b2fecee0f4fbf520510ae7616b48661dd (patch)
treea6dbb73014b8c095042739e3ca72b7a83390a6ee /install.php
parent[install.php] tableHasIndex -> tableGetIndex (diff)
downloadslx-admin-a867108b2fecee0f4fbf520510ae7616b48661dd.tar.gz
slx-admin-a867108b2fecee0f4fbf520510ae7616b48661dd.tar.xz
slx-admin-a867108b2fecee0f4fbf520510ae7616b48661dd.zip
[exams] Fix creating global exam
Diffstat (limited to 'install.php')
-rw-r--r--install.php7
1 files changed, 5 insertions, 2 deletions
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) {