This repository has been archived on 2025-02-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tp_twigg/tpCrudTwig/src/DataBase.php
2024-10-23 21:45:15 +02:00

26 lines
392 B
PHP

<?php
function ConnectDataBase()
{
global $db;
try {
$host = "localhost";
$user = "root";
$password = "motdepasse";
// Connexion à la bdd
$db = new PDO("mysql:host=$host;dbname=cruddb", $user, $password);
$db->exec('SET NAMES "UTF8"');
} catch (PDOException $e) {
echo 'Erreur : ' . $e->getMessage();
die();
}
}
function CloseDataBase()
{
global $db;
$db = null;
}