public function modifier(Peripherique $obj) { // Avant de modifier, il faut recupere o1, o2 et o3 pour reconstruire l'adresse ip à la main $sql = "SELECT o1, o2, o3 FROM " . $this->table_name . " WHERE `add_mac`=:add_mac"; $stmt = $this->connection->prepare($sql); $stmt->bindValue("add_mac", $obj->getAdd_mac()); $stmt->execute(); $ips = $stmt->fetchAll(); $obj->setAdd_ip($ips[0]["o1"] . "." . $ips[0]["o2"] . "." . $ips[0]["o3"] . "." . $obj->getOctet4()); $sql = "UPDATE " . $this->table_name . " SET `hostname`=:hostname, `description`=:description, `type`=:type, `add_mac`=:add_mac, `add_ip`=:add_ip,\n `proprietaire`=:proprietaire, `proprietaire_classe`=:proprietaire_classe WHERE `id` = :id"; $stmt = $this->connection->prepare($sql); $stmt->bindValue("id", $obj->getId()); $stmt->bindValue("hostname", $obj->getHostname()); $stmt->bindValue("description", $obj->getDescription()); $stmt->bindValue("type", $obj->getType()); $stmt->bindValue("add_mac", $obj->getAdd_mac()); $stmt->bindValue("add_ip", $obj->getAdd_ip()); $stmt->bindValue("proprietaire", $obj->getProprietaire()); $stmt->bindValue("proprietaire_classe", $obj->getProprietaire_classe()); $stmt->execute(); }