<?php
/**
 * @author MR MILLS ABIEKU GODFRED
 *
 * ConnectionDao Class - Provides database connection 
 * with a static function "getDb()" to be implemented by other DAO classes
 */
class ConnectionDao {
    
    const DB_SERVER     = "127.0.0.1";
    const DB_USER       = "root";
    const DB_PASSWORD   = "";
    const DB_NAME       = "otsms";
    // const DB_NAME       = "nkysms";
    
    public static function getDb(){
        $dsn = 'mysql:dbname='.self::DB_NAME.';host='.self::DB_SERVER;

        try {
            $db = new \PDO($dsn, self::DB_USER, self::DB_PASSWORD);
        } catch (PDOException $e) {
            throw new \Exception('Connection failed: ');
        }
        
        return $db;
    }
    
        
}
?>
