modification pdo
This commit is contained in:
37
Class/class.newFiche.php
Normal file
37
Class/class.newFiche.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
class Class_newFiche
|
||||
{
|
||||
private $pdo = null;
|
||||
|
||||
|
||||
public function __construct(PdoGsb $pDO)
|
||||
{
|
||||
$this->pdo = $pDO->getPdoGsb();
|
||||
}
|
||||
|
||||
|
||||
public function listFraisForfaitaires(): array
|
||||
{
|
||||
$req = 'SELECT "fLibelle", "fMontant" FROM forfait';
|
||||
$result = $this->pdo->prepare($req);
|
||||
$result->execute();
|
||||
|
||||
return $result->fetchAll();
|
||||
}
|
||||
|
||||
public function endInter(string $id)
|
||||
{
|
||||
$req = "UPDATE intervention
|
||||
SET iHeureFin = NOW()
|
||||
WHERE iCis = :cis AND iId = :idInter AND iHeureFin IS NULL";
|
||||
|
||||
$cis = explode('-', $id)[0];
|
||||
$idInter = explode('-', $id)[1];
|
||||
|
||||
$result = PdoBD::$monPdo->prepare($req);
|
||||
$result->bindParam(':cis', $cis);
|
||||
$result->bindParam(':idInter', $idInter);
|
||||
$result->execute();
|
||||
}
|
||||
}
|
||||
34
Class/class.pdo.php
Normal file
34
Class/class.pdo.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
class PdoGsb
|
||||
{
|
||||
private static $serveur = 'pgsql:host=localhost';
|
||||
private static $bdd = 'dbname=gsb2024';
|
||||
private static $user = 'postgres';
|
||||
private static $mdp = 'postgres';
|
||||
private static $pdo;
|
||||
private static $monPdoGsb = null;
|
||||
/**
|
||||
* Constructeur prive, cree l'instance de PDO qui sera sollicitee
|
||||
* pour toutes les methodes de la classe
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
PdoGsb::$pdo = new PDO(PdoGsb::$serveur . ';' . PdoGsb::$bdd, PdoGsb::$user, PdoGsb::$mdp);
|
||||
|
||||
//PdoGsb::$monPdo->query("SET CHARACTER SET utf8");SET client_encoding = 'UTF8';
|
||||
}
|
||||
public function _destruct()
|
||||
{
|
||||
PdoGsb::$monPdo = null;
|
||||
}
|
||||
/**
|
||||
* Fonction statique qui cree l'unique instance de la classe
|
||||
* Appel : $instancePdoGsb = PdoGsb::getPdoGsb();
|
||||
* @return pdo
|
||||
*/
|
||||
public function getPdoGsb()
|
||||
{
|
||||
return PdoGsb::$pdo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user