WebServ/www/public/M6/inc/egytalk_connect.php

22 lines
696 B
PHP
Raw Normal View History

2024-09-19 11:47:33 +00:00
<?php
2024-09-24 13:06:22 +00:00
if (!defined('DB_USER')) {
define('DB_USER', 'egytalk');
}
if (!defined('DB_PASSWORD')) {
define('DB_PASSWORD', '12345');
}
if (!defined('DB_HOST')) {
2024-10-07 06:18:58 +00:00
define('DB_HOST', 'mariadb'); // Use 'mariadb' for Docker, otherwise '127.0.0.1'
2024-09-24 13:06:22 +00:00
}
if (!defined('DB_NAME')) {
define('DB_NAME', 'egytalk');
}
// Check if the PDO connection is already created
if (!isset($db)) {
$dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8';
$db = new PDO($dsn, DB_USER, DB_PASSWORD);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Enable exception handling
}
return $db;
2024-09-19 11:47:33 +00:00
?>