예제 #1
0
	public function recuperarImagem($id_imagem){

		$query ="SELECT tbl_prova_pergunta_imagem.imagem         AS imagem,
						tbl_prova_pergunta_imagem.prova_pergunta AS pergunta,
						tbl_prova_pergunta_imagem.descricao      AS descricao,
						tbl_prova_pergunta_imagem.path           AS path,
						tbl_prova_pergunta_imagem.thumb          AS thumb
				FROM tbl_prova_pergunta_imagem
				WHERE tbl_prova_pergunta_imagem.imagem = ".$id_imagem;

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

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

			while($linha = $banco->fetchArray($retorno)) {
				$imagem = new Imagem(); 
				$imagem->setId($linha['imagem']);
				$imagem->setPergunta($linha["pergunta"]);
				$imagem->setDescricao($linha["descricao"]);
				$imagem->setPath($linha["path"]);
				$imagem->setThumb($linha["thumb"]);
			}
			return $imagem; 
		} else {
			throw new Exception("Erro ao recuperar Imagem ($query)"); 
		}
	}
예제 #2
0
				foreach ($l as $i => $v) {
					if (!array_key_exists($i, $files)) {
						$files[$i] = array();
					}
					$files[$i][$k] = $v;
				}
			}
		}

		foreach ($files as $file) {
			$handle = new Upload($file);
			if ($handle->uploaded) {

				$obj_imagem = new Imagem();
				$obj_imagem->setPergunta($perg->getId());
				$obj_imagem->setDescricao('');
				
				$path_imagem = "perguntas/imagens/";
				$path_thumb  = "perguntas/imagens/";

				#Resize
				$handle->image_resize            = true;
				$handle->image_ratio_y           = true;
				$handle->image_x                 = 640;
				$handle->file_name_body_add      = "_".$perg->getId();

				$handle->Process($path_imagem);
				if ($handle->processed) {
					$path_imagem = $handle->file_dst_pathname;
					$obj_imagem->setPath($path_imagem);
				} else {