$church->setAddress($_GET["addressChurch"]); $church->setColony($_GET["colonyChurch"]); $church->setPostalCode($_GET["postalCodeChurch"]); $church->setPhoneNumber($_GET["phoneNumberChurch"]); $church->setIdVicar(ChurchManager::getSingleVicar('name', $_GET["vicar"])->getId()); $church->setIdDean(ChurchManager::getSingleDean('name', $_GET["dean"])->getId()); $church->setIdCity(CityManager::getSingleCity('name', $_GET["city"])->getId()); $niches = $_GET["niche"]; if ($niches == 'true') { $niche = new Niche(); $niche->setMaxCol($_GET["maxCol"]); $niche->setMaxRow($_GET["maxRow"]); $niche->setSize($_GET["size"]); $nicheT = ChurchManager::getSingleNiche('maxCol', $niche->getMaxCol(), 'maxRow', $niche->getMaxRow(), 'size', $niche->getSize()); if ($nicheT === NULL) { ChurchManager::addNiche($niche); $nicheT = ChurchManager::getSingleNiche('maxCol', $niche->getMaxCol(), 'maxRow', $niche->getMaxRow(), 'size', $niche->getSize()); $church->setIdNiche($nicheT->getId()); } else { $church->setIdNiche($nicheT->getId()); } } else { $church->setIdNiche('NULL'); } if ($status === 'update') { $church->setId($_GET["id"]); if (ChurchManager::updateChurch($church)) { echo "OK"; } else { echo "KO"; }