First Commit
This commit is contained in:
39
html/sternwarte/intern/sofue/copyDB.php
Executable file
39
html/sternwarte/intern/sofue/copyDB.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
# In der datenbank 'sternwarte' die aktuellen
|
||||
# Tabellen SoFue, StatistikJahr und StatistikGesamt
|
||||
# in jeweils Test.Tabellen (t_SoFue, t_StatistikJahr und t_StatistikGesamt) rüberkopieren
|
||||
|
||||
# Definitionen
|
||||
$host = 'stern-mysql';
|
||||
$user = 'root';
|
||||
$pass = 'SFluorit';
|
||||
$dbase = 'sternwarte';
|
||||
$from1 = 'SoFue';
|
||||
// $from2 = 'StatistikJahre';
|
||||
// $from3 = 'StatistikGesamt';
|
||||
$to1 = 't_SoFue';
|
||||
// $to2 = 't_StatistikJahre';
|
||||
// $to3 = 't_StatistikGesamt';
|
||||
|
||||
date_default_timezone_set('Europe/Berlin');
|
||||
|
||||
$dbh = mysqli_connect($host,$user,$pass) or die ("Couldn't connect to the database.");
|
||||
mysqli_select_db($dbh,$dbase) or die ("Couldn't select database");
|
||||
mysqli_query($dbh, "SET NAMES 'utf8'");
|
||||
mysqli_query($dbh, "SET CHARACTER SET 'utf8'");
|
||||
|
||||
// Einlesen einer Tabelle und rausspeichern auf die Test-Tabelle
|
||||
function copyTable($dbh,$from,$to) {
|
||||
$query = "drop table if exists $to";
|
||||
$result = mysqli_query($dbh,$query) or die (mysqli_error($dbh));
|
||||
$query = "create table $to select * from $from";
|
||||
$result = mysqli_query($dbh,$query) or die (mysqli_error($dbh));
|
||||
echo "Copy $from nach $to. Erg: " . $result . "<br />";
|
||||
}
|
||||
|
||||
copyTable($dbh, $from1, $to1);
|
||||
// copyTable($dbh, $from2, $to2);
|
||||
// copyTable($dbh, $from3, $to3);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user