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,19 @@
<?php
include_once 'include/chargementClasses.php';
try{
$laConnexion = new ConnexionBDD();
$sql = 'SELECT * FROM intervention INNER JOIN arbre ON arbre.id = intervention.idArbre;';
$reponse = $laConnexion->dbh()->query($sql);
$output = array("lesInterventions"=>$reponse->fetchAll(PDO::FETCH_ASSOC));
}catch (Exception $e){
die('Erreur : '.$e->getMessage());
}
echo(json_encode($output));

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;
}
}

View File

@@ -0,0 +1,7 @@
<?php
spl_autoload_register('chargerClasse');
function chargerClasse($classe){
require "include/".$classe.".php";
}

View File

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<!--
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.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
// put your code here
?>
</body>
</html>

View File

@@ -0,0 +1,6 @@
copy.src.files=false
copy.src.on.open=false
copy.src.target=/var/www/PhpProject1
index.file=index.php
run.as=LOCAL
url=http://localhost/PHPProjects/ONF/

View File

@@ -0,0 +1,7 @@
include.path=${php.global.include.path}
php.version=PHP_80
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
web.root=.

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>ONF</name>
</data>
</configuration>
</project>