src/DBConfig.php
public static function initiate(array $params)
    {
        try {
            //  Check whether $params is an array or not
            if (!is_array($params)) {
                throw new \Exception('Parameters need to be as an associative array');
            }

            // Initiate database hostname.
            if (isset($params['db_hostname'])) {
                self::$db_params['db_hostname'] = $params['db_hostname'];
            } else {
                throw new \Exception('Database host need to be set!');
            }

            // Initiate  database driver.
            if (isset($params['db_driver'])) {
                self::$db_params['db_driver'] = $params['db_driver'];
            } else {
                throw new \Exception('Database driver need to be set!');
            }

            // Initiate database port
            if (isset($params['db_port'])) {
                self::$db_params['db_port'] = ":" . $params['db_port'];
            } else {
                self::$db_params['db_port'] = "";
            }

            // Initiate database schema
            if (isset($params['db_schema'])) {
                self::$db_params['db_schema']= $params['db_schema'];
            } else {
                throw new \Exception('Database name need to be set!');
            }

            // Initiate database username
            if (isset($params['db_username'])) {
                self::$db_params['db_username'] = $params['db_username'];
            } else {
                self::$db_params['db_username'] = "";
            }

            // Initiate database password
            if (isset($params['db_password'])) {
                self::$db_params['db_password'] = $params['db_password'];
            } else {
                self::$db_params['db_password'] = "";
            }
        } catch (\Exception $e) {
            die($e->getMessage());
        }
    }
public static function initiate(array $params)
    {
        try {
            //  Check whether $params is an array or not
            if (!is_array($params)) {
                throw new \Exception('Parameters need to be as an associative array');
            }

            // Initiate database hostname.
            if (isset($params['db_hostname'])) {
                self::$db_params['db_hostname'] = $params['db_hostname'];
            } else {
                throw new \Exception('Database host need to be set!');
            }

            // Initiate  database driver.
            if (isset($params['db_driver'])) {
                self::$db_params['db_driver'] = $params['db_driver'];
            } else {
                throw new \Exception('Database driver need to be set!');
            }

            // Initiate database port
            if (isset($params['db_port'])) {
                self::$db_params['db_port'] = ":" . $params['db_port'];
            } else {
                self::$db_params['db_port'] = "";
            }

            // Initiate database schema
            if (isset($params['db_schema'])) {
                self::$db_params['db_schema']= $params['db_schema'];
            } else {
                throw new \Exception('Database name need to be set!');
            }

            // Initiate database username
            if (isset($params['db_username'])) {
                self::$db_params['db_username'] = $params['db_username'];
            } else {
                self::$db_params['db_username'] = "";
            }

            // Initiate database password
            if (isset($params['db_password'])) {
                self::$db_params['db_password'] = $params['db_password'];
            } else {
                self::$db_params['db_password'] = "";
            }
        } catch (\Exception $e) {
            die($e->getMessage());
        }
    }
public static function initiate ( array $ params ) { try { //  Check whether $params is an array or not if ( ! is_array ( $ params ) ) { throw new \ Exception ( 'Parameters need to be as an associative array' ) ; } // Initiate database hostname. if ( isset ( $ params [ 'db_hostname' ] ) ) { self :: $ db_params [ 'db_hostname' ] = $ params [ 'db_hostname' ] ; } else { throw new \ Exception ( 'Database host need to be set!' ) ; } // Initiate  database driver. if ( isset ( $ params [ 'db_driver' ] ) ) { self :: $ db_params [ 'db_driver' ] = $ params [ 'db_driver' ] ; } else { throw new \ Exception ( 'Database driver need to be set!' ) ; } // Initiate database port if ( isset ( $ params [ 'db_port' ] ) ) { self :: $ db_params [ 'db_port' ] = ":" . $ params [ 'db_port' ] ; } else { self :: $ db_params [ 'db_port' ] = "" ; } // Initiate database schema if ( isset ( $ params [ 'db_schema' ] ) ) { self :: $ db_params [ 'db_schema' ] = $ params [ 'db_schema' ] ; } else { throw new \ Exception ( 'Database name need to be set!' ) ; } // Initiate database username if ( isset ( $ params [ 'db_username' ] ) ) { self :: $ db_params [ 'db_username' ] = $ params [ 'db_username' ] ; } else { self :: $ db_params [ 'db_username' ] = "" ; } // Initiate database password if ( isset ( $ params [ 'db_password' ] ) ) { self :: $ db_params [ 'db_password' ] = $ params [ 'db_password' ] ; } else { self :: $ db_params [ 'db_password' ] = "" ; } } catch ( \ Exception $ e ) { die ( $ e -> getMessage ( ) ) ; } }
Initiates database configuration parameters
@param  array  $params Database configuration parameters
@return void
Initiates database configuration parameters