<?php



/**

 * Created by PhpStorm.

 * User: Admin

 * Date: 10/6/2017

 * Time: 11:06 AM

 */

class dbConnection

{

    public $dataModel;

    public $DB_HOST;

    public $DB_USERNAME;

    public $DB_PASSWORD;

    public $DB_NAME;

    public $CONNECTION;

    public $TABLES_STRUCTURE;

    public $TABLE_LIST = array();

    public $TABLE_LIST_IN_DB = array();



    public function loadDataModel($dataModel){

        $tablesName = array();

        $this->dataModel = json_decode($dataModel, true);

        $this->DB_HOST = $this->dataModel['database']['host'];

        $this->DB_USERNAME = $this->dataModel['database']['username'];

        $this->DB_PASSWORD = $this->dataModel['database']['password'];

        $this->DB_NAME = $this->dataModel['database']['dataBasename'];

        $this->TABLES_STRUCTURE = $this->dataModel['database']['tables'][0];

        foreach ($this->TABLES_STRUCTURE as $key => $value){

            $this->TABLE_LIST[] = $key;

        }

    }



}



$connection = new dbConnection();

$connection->loadDataModel(file_get_contents('model/dataModel.json'));

$connection->CONNECTION = mysqli_connect($connection->DB_HOST, $connection->DB_USERNAME, $connection->DB_PASSWORD, $connection->DB_NAME);

?>