Skip to content
Snippets Groups Projects
Commit 2423e9c0 authored by goujonpa's avatar goujonpa
Browse files
parents f9ec9296 cb3a8ff2
No related branches found
No related tags found
No related merge requests found
......@@ -89,4 +89,44 @@ class Objet
throw new Exception("RESULT : ".print_r($result,true)."\n".print_r($requete_prepare->errorInfo(),true));
}
}
public function update()
{
$dbName = self::dbName();
$bdd = new Db();
$values = array();
$params = array();
foreach(array_keys(get_object_vars($this)) as $keyName) {
if($keyName == "primaryAttr") { continue; }
$params[$keyName] = $this->$keyName;
if($keyName == $this->primaryAttr) { continue; }
$values[$keyName] = $keyName." = :".$keyName;
}
$req = "UPDATE ".$dbName." SET ".implode(",", array_values($values))." WHERE ".$this->primaryAttr." = :".$this->primaryAttr;
$requete_prepare = $bdd->db->prepare($req); // on prépare notre requête
if (!$requete_prepare) {
throw new Exception("PDO::errorInfo(): (STEP 1)\n". print_r($bdd->db->errorInfo(), true));
}
$result = $requete_prepare->execute($params);
if($result != 1) {
throw new Exception("RESULT : ".print_r($result,true)."\n".print_r($requete_prepare->errorInfo(),true));
}
}
public function select($id) {
$dbName = self::dbName();
$bdd = new Db();
$requete_prepare = $bdd->db->prepare("SELECT * FROM ".$dbName." WHERE ".$this->primaryAttr." = :id"); // on prépare notre requête
$requete_prepare->execute(array("id" => $id));
$ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC);
$this->fromDb($ligne);
}
}
\ No newline at end of file
......@@ -38,11 +38,13 @@ switch($action) {
break;
case "editPersonnel":
$employe = new Employe();
$employe->select($_GET['id']);
$formConf = $employe->getForm();
include 'view/form.php';
break;
case "editClient":
$client = new Client();
$client->select($_GET['id']);
$formConf = $client->getForm();
include 'view/form.php';
break;
......
......@@ -4,7 +4,7 @@
width: 100%;
/* Set the fixed height of the footer here */
height: 30px;
background-color: #f5f5f5;
background-color: #108a93;
}
.footer-container {
......
......@@ -12,9 +12,9 @@
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://tuxa.sme.utc/~nf17p110/css/bootstrap.css">
<link rel="stylesheet" href="http://tuxa.sme.utc/~nf17p110/css/custom_bootstrap.css">
<link href="http://tuxa.sme.utc/~nf17p110/css/sticky-footer.css" rel="stylesheet">
<link rel="stylesheet" href="http://tuxa.sme.utc/~nf17p110/css/custom_bootstrap.css">
<!-- Optional theme -->
<link rel="icon" type="image/png" href="http://tuxa.sme.utc/~nf17p110/img/logo.png" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment