Consolidated setup files into one setup.php, creates default content and tables

This commit is contained in:
root
2019-06-10 18:09:53 -04:00
parent a81f78a131
commit 99e7307c62
5 changed files with 91 additions and 10 deletions

35
createtables.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
//DB Settings
$dbhost = "localhost";
$dbusername = "root";
$dbpassword = "password";
$database = "test";
$mysqli = mysqli_connect($dbhost, $dbusername, $dbpassword, $database);
// Name of the file
$filename = 'db.sql';
// Temporary variable, used to store current query
$templine = '';
// Read in entire file
$lines = file($filename);
// Loop through each line
foreach ($lines as $line){
// Skip it if it's a comment
if(substr($line, 0, 2) == '--' || $line == '')
continue;
// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if(substr(trim($line), -1, 1) == ';'){
// Perform the query
mysqli_query($mysqli,$templine);
// Reset temp variable to empty
$templine = '';
}
}
?>