Created
April 2, 2023 13:55
-
-
Save marceljuenemann/f45df9919fc283bebbc724a9f2f4318a to your computer and use it in GitHub Desktop.
DSB DWZ Datenbank aktualisieren
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function autodwz ( $lv, $db ) | |
{ | |
$zip = new ZipArchive; | |
$url = "https://dwz.svw.info/services/files/export/sql/LV-$lv-sql.zip"; | |
echo "Lade $lv.\r\n"; | |
if ( !copy ( $url, "dwz.zip" ) ) | |
{ echo "Fehler!"; return; } | |
$res = $zip->open("dwz.zip"); | |
if ($res === TRUE) | |
{ | |
$sql = explode ( "\n", $zip->getFromName('vereine.sql') ); | |
if ( count ( $sql ) > 10 ) | |
{ | |
if ( !query ( "DELETE FROM dwz_vereine WHERE ZPS LIKE '$lv%'", $db ) ) | |
echo "Fehler beim Leeren!<br>"; | |
foreach ( $sql as $q ) | |
{ | |
if ( trim ( $q ) ) { | |
if ( !query ( trim ( $q ), $db ) ) | |
echo "Fehler in Abfrage: ".trim($q)."<br>"; | |
} | |
} | |
} | |
else | |
echo "Fehler beim Öffnen!<br>"; | |
$sql = explode ( "\n", $zip->getFromName('spieler.sql') ); | |
if ( count ( $sql ) > 10 ) | |
{ | |
if ( !query ( "DELETE FROM dwz_spieler WHERE ZPS LIKE '$lv%'", $db ) ) | |
echo "Fehler beim Leeren!<br>"; | |
foreach ( $sql as $q ) | |
{ | |
if ( $q = trim ( $q ) ) | |
if ( !query ( $q, $db ) ) | |
echo "Fehler in Abfrage: ".trim($q)."<br>"; | |
} | |
query ( "UPDATE dwz_spieler SET geschlecht='M' WHERE geschlecht is null", $db ); | |
} | |
else | |
echo "Fehler beim Öffnen!<br>"; | |
$zip->close (); | |
} | |
else | |
echo "Fehler beim Öffnen!<br>"; | |
} | |
function query ( $q, $db ) | |
{ | |
return mysql_query ( $q, $db ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment