public function create(User $user, $address, $post_code, $city, $complement) { $ad_facturation = new Ad_facturation(); if (isset($_SESSION['id']) && $_SESSION['id'] == $user->getId()) { $set = $ad_facturation->setAdress($address); if ($set === true) { $set = $ad_facturation->setPostCode($post_code); if ($set === true) { $set = $ad_facturation->setCity($city); if ($set === true) { $set = $ad_facturation->setComplement($complement); if ($set === true) { $idUser = intval($user->getId()); $address = $this->database->quote($ad_facturation->getAddress()); $postCode = $this->database->quote($ad_facturation->getPostCode()); $city = $this->database->quote($ad_facturation->getCity()); $complement = $this->database->quote($ad_facturation->getComplement()); $query = "INSERT INTO ad_facturation (id_user, address, post_code, city, complement)\n\t\t\t\t\t\t\t\tVALUES (" . $idUser . ", '" . $address . "', '" . $postCode . "', '" . $city . "', '" . $complement . "')"; $result = $this->database->exec($query); if ($result) { $id = $this->database->lastInsertId(); if ($id) { return $this->findById($id); } else { throw new Exception("Catastrophe serveur."); } } else { throw new Exception("Catastrophe base de données."); } } else { throw new Exception($set); } } else { throw new Exception($set); } } else { throw new Exception($set); } } else { throw new Exception($set); } } else { throw new Exception("Erreur compte utilisateur."); } }