Пример #1
0
 function write()
 {
     $bdd = new Connector();
     $promo = $bdd->Select("*", "promo", array("where" => array(array("id_promo", "=", $this->id_promo))));
     if (!$promo) {
         throw new UnexpectedValueException("La promo n'existe plus en base de données");
     }
     $promo = $promo[0];
     $attrs = get_object_vars($this);
     $toUpdate = array();
     foreach ($attrs as $key => $value) {
         if ($value != $promo[$key]) {
             $toUpdate[$key] = $value;
         }
     }
     $bdd->Update("promo", array("set" => $toUpdate, "where" => array(array("id_promo", "=", $this->id_promo))));
 }
Пример #2
0
 function write()
 {
     $bdd = new Connector();
     $data = $bdd->Select("*", "data", array("where" => array(array("identifiant", "=", $this->identifiant))));
     if (!$data) {
         throw new UnexpectedValueException("Les données n'existent plus en base de données");
     }
     $data = $data[0];
     $attrs = get_object_vars($this);
     $toUpdate = array();
     foreach ($attrs as $key => $value) {
         if ($value != $data[$key]) {
             $toUpdate[$key] = $value;
         }
     }
     $bdd->Update("data", array("set" => $toUpdate, "where" => array(array("identifiant", "=", $this->identifiant))));
 }
Пример #3
0
 function changeRank($newRank)
 {
     $bdd = new Connector();
     // Change promo in both object and BDD
     $this->rang = $newRank;
     $bdd->Update("document", array("where" => array(array("id", "=", $this->id)), "set" => array("rang" => $this->rang)));
 }