Ejemplo n.º 1
0
 public function crearPregunta($idPadre, $tipoPadre, Encuesta_Model_Pregunta $pregunta)
 {
     if ($tipoPadre === "S") {
         $tablaSeccion = $this->tablaSeccion;
         $select = $tablaSeccion->select()->from($tablaSeccion)->where("idSeccion = ?", $idPadre);
         $rowSeccion = $tablaSeccion->fetchRow($select);
         $rowSeccion->elementos++;
         $rowSeccion->save();
         $pregunta->setOrden($rowSeccion->elementos);
     } elseif ($tipoPadre === "G") {
         $tablaGrupo = $this->tablaGrupo;
         $select = $tablaGrupo->select()->from($tablaGrupo)->where("idGrupo = ?", $idPadre);
         $rowGrupo = $tablaGrupo->fetchRow($select);
         $rowGrupo->elementos++;
         $rowGrupo->save();
         $pregunta->setOrden($rowGrupo->elementos);
     }
     $pregunta->setHash($pregunta->getHash());
     $pregunta->setFecha(date("Y-m-d H:i:s", time()));
     $tablaPregunta = $this->tablaPregunta;
     $tablaPregunta->insert($pregunta->toArray());
     $pregunta = $this->obtenerPreguntaHash($pregunta->getHash());
     return $pregunta;
 }