mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-25 19:42:30 +00:00
Includes install system just go to /install in the browser and follow the on screen instructions
This commit is contained in:
47
install/includes/database_class.php
Normal file
47
install/includes/database_class.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class Database {
|
||||
|
||||
// Function to the database and tables and fill them with the default data
|
||||
function create_database($data)
|
||||
{
|
||||
// Connect to the database
|
||||
$mysqli = new mysqli($data['hostname'],$data['username'],$data['password'],'');
|
||||
|
||||
// Check for errors
|
||||
if(mysqli_connect_errno())
|
||||
return false;
|
||||
|
||||
// Create the prepared statement
|
||||
$mysqli->query("CREATE DATABASE IF NOT EXISTS ".$data['database']);
|
||||
|
||||
// Close the connection
|
||||
$mysqli->close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Function to create the tables and fill them with the default data
|
||||
function create_tables($data)
|
||||
{
|
||||
// Connect to the database
|
||||
$mysqli = new mysqli($data['hostname'],$data['username'],$data['password'],$data['database']);
|
||||
|
||||
// Check for errors
|
||||
if(mysqli_connect_errno())
|
||||
return false;
|
||||
|
||||
// Open the default SQL file
|
||||
$query = file_get_contents('assets/install.sql');
|
||||
|
||||
// Execute a multi query
|
||||
$mysqli->multi_query($query);
|
||||
|
||||
// Close the connection
|
||||
$mysqli->close();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user