Initial commit

This commit is contained in:
Porawit Dongwang
2026-09-16 23:20:08 +07:00
commit 0041668dbb
32577 changed files with 3687927 additions and 0 deletions
@@ -0,0 +1,68 @@
<?php
/**
* Database Configuration
*/
define('DB_HOST', 'localhost');
define('DB_PORT', '3306');
define('DB_NAME', 'ksh_payroll');
define('DB_USER', 'root');
define('DB_PASS', '@Samui@10742');
define('DB_CHARSET', 'utf8mb4');
// HR Database (hosoffice_2566) Connection Details
define('HR_DB_HOST', '10.0.250.115'); // <-- เปลี่ยนเป็น IP ของ HR Server
define('HR_DB_PORT', '3306');
define('HR_DB_NAME', 'hosoffice_2566');
define('HR_DB_USER', 'hosoffice'); // <-- เปลี่ยนเป็น Username ของ HR
define('HR_DB_PASS', 'hosoffice10742'); // <-- เปลี่ยนเป็น Password ของ HR
define('HR_DB_CHARSET', 'utf8mb4'); // หรือ utf8mb4 ขึ้นอยู่กับฐานข้อมูล HR
class Database
{
private static $instance = null;
private static $hrInstance = null;
private $pdo;
private function __construct($type = 'default')
{
if ($type === 'hr') {
$dsn = "mysql:host=" . HR_DB_HOST . ";port=" . HR_DB_PORT . ";dbname=" . HR_DB_NAME . ";charset=" . HR_DB_CHARSET;
$user = HR_DB_USER;
$pass = HR_DB_PASS;
} else {
$dsn = "mysql:host=" . DB_HOST . ";port=" . DB_PORT . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET;
$user = DB_USER;
$pass = DB_PASS;
}
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$this->pdo = new PDO($dsn, $user, $pass, $options);
} catch (\PDOException $e) {
throw new \PDOException($e->getMessage(), (int)$e->getCode());
}
}
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new self('default');
}
return self::$instance->pdo;
}
public static function getHrConnection()
{
if (self::$hrInstance === null) {
self::$hrInstance = new self('hr');
}
return self::$hrInstance->pdo;
}
}