Database Configuration

SkyMake does not automatically create tables, please run install.sql manually to install the database.

SkyMake db configuration file's template looks like this. It has commented areas for you to be able to switch between multidomain and single domain installation.

<?php
/*
* SkyMake 4 Database Configuration File
* Setup your database and MULTIDB  here.
* After configuration is complete,
* rename this file to SkyMakeDBconfig.php
* (remove .template from the end)
* SM4CONF V2 - Skyfallen SkyMake 4
*/


// this value is checked in order to make sure we have access to this file
define("SkyMakeOnDBConfigConnect", "DBCONFCONNOK");
$dbconfig = array();
$dbcurrent = array();
//begin editing for your own database


//Uncomment this if you want to use the install with a single db.
define("ALLOW_MULTIDB",false);
$dbconfig["default"]["dbhost"] = "dbserver";
$dbconfig["default"]["dbname"] = "skymake_db";
$dbconfig["default"]["dbuser"] = "root";
$dbconfig["default"]["dbpassword"] = "dbpassword";

/*
    //Uncomment this if you want  to use multidb
    //Note: Comment the default part before doing this
    //Note: Replace parts between ### with your own data.
    define("ALLOW_MULTIDB",true);
    //Replace the following part with this when you enable multidb
    $dbconfig["###yourmaindomainwithouttldordot###"]["dbhost"] = "###dbserver###";
    $dbconfig["###yourmaindomainwithouttldordot###"]["dbname"] = "###skymake_db###";
    $dbconfig["###yourmaindomainwithouttldordot###"]["dbuser"] = "###root###";
    $dbconfig["###yourmaindomainwithouttldordot###"]["dbpassword"] = "###dbpassword###";
    Copy this template for every multidb subdomin
    $dbconfig["###yoursubdomain###"]["dbhost"] = "###dbserver###";
    $dbconfig["###yoursubdomain###"]["dbname"] = "###skymake_db###";
    $dbconfig["###yoursubdomain###"]["dbuser"] = "###root###";
    $dbconfig["###yoursubdomain###"]["dbpassword"] = "##dbpassword###";
*/
//stop editing
if(!defined("ALLOW_MULTIDB")){
    include_once(__DIR__."/../SkyMakeFunctionSet/Mission-Critical-Functions/SMC.php");
    SMC::displayCrash("This SkyMake4 instance is not configured. Please check your configuration. ERROR_CODE: SM4_CNFV2_NOCONFIG","Failed to load","There is an issue in the SkyMake Database Configuration file.");
    die();
}
if(ALLOW_MULTIDB){
    $url = $_SERVER["HTTP_HOST"];
    $parsedUrl = parse_url($url);
    $host = explode('.', $parsedUrl['host']);
    $subdomain = $host[0];
    if(isset($dbconfig[$subdomain]["dbname"])){
        $dbcurrent["host"] = $dbconfig[$subdomain]["dbhost"];
        $dbcurrent["user"] = $dbconfig[$subdomain]["dbuser"];
        $dbcurrent["password"] = $dbconfig[$subdomain]["dbpassword"];
        $dbcurrent["name"] = $dbconfig[$subdomain]["dbname"];
    } else {
      include_once(__DIR__."/../SkyMakeFunctionSet/Mission-Critical-Functions/SMC.php");
      SMC::displayCrash("There is a problem with this SkyMake Setup. Please check your configuration. ERROR_CODE: MULTIDB_UNKNOWN_DOMAIN","Failed to Configure this Namespace","There was a issue in the SkyMake Database Configuration file.");
      die();
    }
} else {
    $dbcurrent["host"] = $dbconfig["default"]["dbhost"];
    $dbcurrent["user"] = $dbconfig["default"]["dbuser"];
    $dbcurrent["password"] = $dbconfig["default"]["dbpassword"];
    $dbcurrent["name"] = $dbconfig["default"]["dbname"];
}

/* Attempt to connect to MySQL database */
$link = mysqli_connect($dbcurrent["host"], $dbcurrent["user"], $dbcurrent["password"], $dbcurrent["name"]);

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
$linktwo = mysqli_connect($dbcurrent["host"], $dbcurrent["user"], $dbcurrent["password"], $dbcurrent["name"]);

// Check connection
if($linktwo === false){
    die("ERROR: Could not create seconday dblink. " . mysqli_connect_error());
}
?>

In here, please notice the comments that say start & stop editing.

These are used to tell you that the rest of the file is real application code, so please do not touch these parts.

Multi Config Installation

For multi config installation, you first need to comment the single domain config like this.

/*
//Uncomment this if you want to use the install with a single db.
define("ALLOW_MULTIDB",false);
$dbconfig["default"]["dbhost"] = "dbserver";
$dbconfig["default"]["dbname"] = "skymake_db";
$dbconfig["default"]["dbuser"] = "root";
$dbconfig["default"]["dbpassword"] = "dbpassword";
*/

Then, you need to uncomment (remove '/*' and '*/') from the beginning of the multiconfig part which looks like this.

/*
    //Uncomment this if you want  to use multidb
    //Note: Comment the default part before doing this
    //Note: Replace parts between ### with your own data.
    define("ALLOW_MULTIDB",true);
    //Replace the following part with this when you enable multidb
    $dbconfig["###yourmaindomainwithouttldordot###"]["dbhost"] = "###dbserver###";
    $dbconfig["###yourmaindomainwithouttldordot###"]["dbname"] = "###skymake_db###";
    $dbconfig["###yourmaindomainwithouttldordot###"]["dbuser"] = "###root###";
    $dbconfig["###yourmaindomainwithouttldordot###"]["dbpassword"] = "###dbpassword###";
    Copy this template for every multidb subdomin
    $dbconfig["###yoursubdomain###"]["dbhost"] = "###dbserver###";
    $dbconfig["###yoursubdomain###"]["dbname"] = "###skymake_db###";
    $dbconfig["###yoursubdomain###"]["dbuser"] = "###root###";
    $dbconfig["###yoursubdomain###"]["dbpassword"] = "##dbpassword###";
*/

For each subdomain you have, you need to define separate config options, but before all, you need to set the main domain.

Notice the part that says,

###yourmaindomainwithouttldordot###

This means, if your main domain is, for example, theskyfallen.com, you should only type it as "theskyfallen".

If your main domain is a subdomain, you should only type the part before the first dot. For example, 'app' for 'app.deducated.com' or 'skymake' for 'skymake.subdomain.yourdomain.com'.

Then, you need to copy this line for each subdomain you would like to make a configuration for.

Copy this template for every multidb subdomin
    $dbconfig["###yoursubdomain###"]["dbhost"] = "###dbserver###";
    $dbconfig["###yoursubdomain###"]["dbname"] = "###skymake_db###";
    $dbconfig["###yoursubdomain###"]["dbuser"] = "###root###";
    $dbconfig["###yoursubdomain###"]["dbpassword"] = "##dbpassword###";

Replace '###yoursubdomain###' with your subdomain. Make sure all of your options are on a new line.

Do not remove the quotes from the code snippets, this will cause a PHP Error.

Single Domain Configuration

The database comes with a single domain installation by default

//Uncomment this if you want to use the install with a single db.
define("ALLOW_MULTIDB",false);
$dbconfig["default"]["dbhost"] = "dbserver";
$dbconfig["default"]["dbname"] = "skymake_db";
$dbconfig["default"]["dbuser"] = "root";
$dbconfig["default"]["dbpassword"] = "dbpassword";

Set your values and leave it as is.

After the configuration is complete, rename this file to SkyMakeDBconfig.php (remove .template from the end)

Last updated