<?php

 $GLOBALS['database'] = "hrm";
 $GLOBALS['username'] = "root";
 $GLOBALS['password'] = "";
 $GLOBALS['hostname'] = "localhost";




function globolise($name, $value) {
    $GLOBALS[$name] = $value;
}
function getConnection($connectionType="mysqli"){


    $connection ="";

    if($connectionType == 'mysqli'){
        $connection = new mysqli($GLOBALS['hostname'], $GLOBALS['username'], $GLOBALS['password'], $GLOBALS['database']);
    }else{
        try{
            $connection = new PDO('mysql:host='.$GLOBALS['hostname'].';dbname='.$GLOBALS['database'], $GLOBALS['username'], $GLOBALS['password']);
        }catch(PDOException $e){
            echo("ERROR :".$e->getMessage());
        }
    }
    return $connection;
}
function exe($query){

    $db = getConnection();

    
    $result =  mysqli_query($db, $query);
    echo mysqli_error($db); 
    return $result;

}
function logger($action, $initiator, $payload){
    
}

$GLOBALS['errors'] = array();

function errorsP($errors){
    if(count($errors)> 0){
        echo '
        <div class="alert alert-danger alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        '.$errors[0].'
      </div>
        ';
    }
}
$succcess = null;
function success($succcess){

    if(isset($succcess)){
        echo  '<div class="alert alert-success alert-dismissible fade show ml-4 mr-4" des$designation="alert">
        '.$succcess.'
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>';
       }
}
session_start();


?>