private function excluirQuestionario() { if (!$_POST) { $nrVersaoDocumento = $_GET['nrVersaoDocumento']; $nrFormDocumento = $_GET['nrFormDocumento']; $where = array('nrFormDocumento = ?' => $nrFormDocumento, 'nrVersaoDocumento = ?' => $nrVersaoDocumento); } else { $nrVersaoDocumento = $_POST['nrVersaoDocumento']; $nrFormDocumento = $_POST['nrFormDocumento']; $where = array('nrFormDocumento = ?' => $nrFormDocumento, 'nrVersaoDocumento = ?' => $nrVersaoDocumento); } $tbRespostaDAO = new tbResposta(); $tbOpcaoRespostaDAO = new tbOpcaoResposta(); $tbPerguntaFormDoctoDAO = new tbPerguntaFormDocto(); $tbPerguntaDAO = new tbPergunta(); if (count($tbRespostaDAO->buscar($where)) == 0) { return array(true, ''); } else { if ($tbRespostaDAO->delete($where)) { if (count($tbOpcaoRespostaDAO->buscar($where)) == 0) { return array(true, ''); } else { if ($tbOpcaoRespostaDAO->delete($where)) { $listaPerguntaFormDocto = $tbPerguntaFormDoctoDAO->buscar($where); $verificar = false; if (is_object($listaPerguntaFormDocto)) { foreach ($listaPerguntaFormDocto as $pergunta) { if ($tbPerguntaDAO->delete(array('nrPergunta = ?' => $pergunta->nrPergunta))) { $verificar = true; } else { $verificar = false; } } } else { $verificar = true; } if ($verificar) { if ($tbPerguntaFormDoctoDAO->delete($where)) { return array(true, ''); } else { return array(false, "Erro ao tentar excluir a Pergunta Form Docto."); } } else { return array(false, "Erro ao tentar excluir a Pergunta."); } } else { return array(false, "Erro ao tentar excluir a Opcao Resposta."); } } } else { return array(false, "Erro ao tentar excluir a Resposta."); } } }