1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| <?php
//classe MaBase, se connecter et se deconnecter de la BDD
class MaBase
{
//Attributs
public $conn = NULL;
public $hostname="localhost";
public $dbname="lcesa";
public $username="root";
public $pw="lcesa";
//---------------Méthodes---------------
//Constructeur
public function __construct($hostname, $dbname, $username, $pw)
{
$this->connect($hostname, $dbname, $username, $pw);
}
//Ouverture BDD
public function connect($hostname, $dbname, $username, $pw)
{
try {
$this->conn = new PDO ("mssql:host=$hostname;dbname=$dbname","$username","$pw");
}
catch( PDOException $Exception ) {
echo $Exception->getMessage();
}
}
//Fermeture BDD
public function stopConnect()
{
$this->conn = NULL;
}
}
// --------------------------------------Gestion des techniciens-------------------------------
class Technicien
{
public function doSelectById(Array $id)
{
// code select
}
public function doSelect()
{
$sql = $conn->prepare("SELECT * FROM technicien");
$sql->execute();
return $sql->fetchAll();
}
public function doUpdate()
{
// code update
}
}
?> |