Script de sauvegarde/restauration

This commit is contained in:
noeraphanaud
2022-02-09 10:33:18 +01:00
parent b85cfcdf7e
commit 78b1b1923d
18 changed files with 25526 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
class ConnexionBDD {
private $_dbh; // Chaine de connexion
/**
* Connexion persistante au serveur
* @return \PDO Connexion
*/
public function __construct(){
// Définition des variables de connexion
$user = "ap43";
$pass = "Azerty1+";
$dsn ='mysql:host=localhost;dbname=bdarbre'; //Data Source Name
// Connexion
try {
$this->_dbh = new PDO($dsn, $user, $pass, array(PDO::ATTR_PERSISTENT=>true,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')); // Connexion persistante
}
catch (PDOException $e) {
die("Erreur : " . $e->getMessage());
}
}
/** afficherErreurSQL :
* Affichage de messages lors l'accès à la bdd avec une requete SQL
* @param $message : message a afficher
*/
function afficherErreurSQL($message, $sql="") {
echo $message . "<br />" . $sql . "<br />";
$info = $this->_dbh->errorInfo();
echo "Code erreur : " . $info[0] . ", Message : " . $info[2];
die();
}
function dbh() {
return $this->_dbh;
}
}