diff --git a/system/dbupdate_eine_uid.php b/system/dbupdate_eine_uid.php
index a3bae3c69..f2fe3720e 100644
--- a/system/dbupdate_eine_uid.php
+++ b/system/dbupdate_eine_uid.php
@@ -31,17 +31,41 @@ echo '
';
+$all_tables_to_update =
+array
+(
+ "bis.tbl_bisio",
+ "campus.tbl_lvgesamtnote",
+ "campus.tbl_studentbeispiel",
+);
+
if(!isset($_POST["action"]) || $_POST["action"] != "start")
{
- echo "ACHTUNG!
";
- echo "Folgendes wird geändert:
";
- echo "";
+ $needed = false;
+ foreach($all_tables_to_update as $t)
+ {
+ if(checkForUpdates($db, $t))
+ $needed = true;
+ }
- describeOneChange("bis.tbl_bisio");
- describeOneChange("campus.tbl_lvgesamtnote");
- echo "
";
- echo "";
+
+ if($needed)
+ {
+ echo "ACHTUNG!
";
+ echo "Folgendes wird geändert:
";
+ echo "";
+
+ foreach($all_tables_to_update as $t)
+ describeOneChange($db, $t);
+
+ echo "
";
+ echo "";
+ }
+ else
+ {
+ echo "Es sind keine Änderungen vorzunehmen!
";
+ }
}
else
{
@@ -54,16 +78,27 @@ else
echo 'Pruefe Tabellen und Attribute!
';
- modifyOneTable($db, "campus.tbl_lvgesamtnote");
- modifyOneTable($db, "bis.tbl_bisio");
-
+ foreach($all_tables_to_update as $t)
+ modifyOneTable($db, $t);
}
-function describeOneChange($tablename)
+function describeOneChange($db, $tablename)
{
- echo "".$tablename.": student_uid wird gelöscht!
";
- echo "".$tablename.": prestudent_id wird eingefügt!
";
+ if(!$result = @$db->db_query("SELECT prestudent_id FROM ".$tablename." LIMIT 1;"))
+ {
+ echo "".$tablename.": student_uid wird gelöscht!
";
+ echo "".$tablename.": prestudent_id wird eingefügt!
";
+ }
+}
+
+function checkForUpdates($db, $tablename)
+{
+ if(!$result = @$db->db_query("SELECT prestudent_id FROM ".$tablename." LIMIT 1;"))
+ {
+ return true;
+ }
+ return false;
}