public function recuperarTipoPergunta($id_tipo_pergunta){

		$query ="SELECT tipo_pergunta        AS tipo_pergunta,
						descricao            AS descricao,
						qtde_respostas       AS qtde_respostas,
						imagem               AS imagem
				FROM tbl_tipo_pergunta
				WHERE tipo_pergunta = $id_tipo_pergunta ";

		$banco = $this->getBancoDados(); 
		$tipo_pergunta = NULL; 
		$retorno = $banco->executaSQL($query); 
		if($retorno != NULL) {

			if ($banco->numRows($retorno) == 0){
				throw new Exception("Nenhuma tipo_pergunta encontrado.",0);
			}

			while($linha = $banco->fetchArray($retorno)) { 
				$tipo_pergunta = new TipoPergunta(); 
				$tipo_pergunta->setId($linha['tipo_pergunta']);
				$tipo_pergunta->setDescricao($linha["descricao"]);
				$tipo_pergunta->setQtdeRespostas($linha["qtde_respostas"]);
				$tipo_pergunta->setImagem($linha["imagem"]);
			}
			return $tipo_pergunta; 
		} else {
			throw new Exception("Erro ao recuperar TipoPergunta ($query)"); 
		}
	}
Esempio n. 2
0
 public static function RetornaTipo($codigo)
 {
     $sql = "SELECT Codigo, Descricao ";
     $sql .= "FROM mestipopergunta WHERE Codigo = :pCod;";
     $cnn = Conexao2::getInstance();
     $rs = $cnn->prepare($sql);
     $rs->bindParam(":pCod", $codigo, PDO::PARAM_INT);
     $rs->execute();
     $t = new TipoPergunta();
     while ($tip = $rs->fetch(PDO::FETCH_OBJ)) {
         $t->setCodigo($tip->Codigo);
         $t->setDescricao($tip->Descricao);
     }
     return $t;
 }