main
inicio
This commit is contained in:
22
config/database.php
Normal file
22
config/database.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../app/helpers/env.php';
|
||||
loadEnv();
|
||||
|
||||
function getConnection()
|
||||
{
|
||||
$serverName = $_ENV['DB_HOST'];
|
||||
$connectionOptions = [
|
||||
"Database" => $_ENV['DB_DATABASE'],
|
||||
"Uid" => $_ENV['DB_USERNAME'],
|
||||
"PWD" => $_ENV['DB_PASSWORD'],
|
||||
"CharacterSet" => "UTF-8"
|
||||
];
|
||||
|
||||
$conn = sqlsrv_connect($serverName, $connectionOptions);
|
||||
|
||||
if (!$conn) {
|
||||
die("❌ Error al conectar: " . print_r(sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
return $conn;
|
||||
}
|
||||
Reference in New Issue
Block a user