public function altaAction() { $request = $this->getRequest(); $idEncuesta = $this->getParam("idEncuesta"); $post = $request->getPost(); $this->view->post = $post; if ($request->isPost()) { //Aqui hacemos el alta de preguntas al sistema $post = $request->getPost(); $numContenedores = count($post); $numContenedores--; $secciones = array_values($post); $encabezado = $secciones[0]; $idEncuesta = $encabezado["idEncuesta"]; $registro = $this->registroDAO->obtenerRegistroReferencia($encabezado["referencia"]); //Recorremos todas las secciones for ($index = 1; $index <= $numContenedores; $index++) { //tomamos una seccion $seccion = $secciones[$index]; foreach ($seccion as $idPregunta => $resp) { $pregunta = $this->preguntaDAO->obtenerPregunta($idPregunta); $respuesta = array(); $respuesta["idRegistro"] = $registro->getIdRegistro(); $respuesta["idEncuesta"] = $idEncuesta; $respuesta["idPregunta"] = $idPregunta; $respuesta["respuesta"] = $resp; $modelRespuesta = new Encuesta_Model_Respuesta($respuesta); $modelRespuesta->setHash($modelRespuesta->getHash()); $modelRespuesta->setFecha(date("Y-m-d H:i:s", time())); $this->respuestaDAO->crearRespuesta($idEncuesta, $modelRespuesta); } } } }
public function crearRespuesta($idEncuesta, Encuesta_Model_Respuesta $respuesta) { $tablaRespuesta = $this->tablaRespuesta; $tablaRespuesta->insert($respuesta->toArray()); }