<?php

class dbconnection
{

    private static $connection = null;

    public static function connect($c)
    {
        if (self::$connection == null) {
            try {
                self::$connection = new PDO('mysql:host=' . $c['host'] . ';dbname=' . $c['database'], $c['username'], $c['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4'));
            } catch (PDOException $error) {
                echo "Database Connection Failed";
                //echo 'Error :' . $error->getCode() . ' - ' . $error->getMessage();
                die();
            }
        }
    }

    public static function get()
    {
        return self::$connection;
    }
}
