Exemple #1
0
 function getById($id)
 {
     $conexao = new Conexao();
     $tipoCurso = "sistutor.tipo_curso";
     $dbCon = $conexao->getConexao();
     $tabela = self::$tabela;
     $sql = "select id_curso,nome, polo, id_tipo_curso, descricao from " . self::$tabela . " join {$tipoCurso} on id_tipo_curso = tipo" . " where id_curso=\$1";
     $result = pg_query_params($dbCon, $sql, array($id));
     $curso = 0;
     $linha = pg_fetch_assoc($result);
     if ($linha) {
         $curso = new Curso();
         $nome = $linha['nome'];
         $tipo = array("descricao" => $linha['descricao'], "id" => $linha["id_tipo_curso"]);
         $idPolo = $linha['polo'];
         $id = $linha['id_curso'];
         $polo = (new PoloDao())->getById($idPolo);
         $curso->setId($id);
         $curso->setNome($nome);
         $curso->setPolo($polo);
         $curso->setTipo($tipo);
     }
     $conexao->closeConexao();
     return $curso;
 }
 function update()
 {
     $curso = new Curso();
     $curso->setNome($_POST['nome']);
     $polo = new Polo();
     $polo->setId($_POST['polo']);
     $curso->setPolo($polo->getById());
     $tipo = array('id' => $_POST['tipo']);
     $curso->setTipo($tipo);
     $curso->setId($_POST['id']);
     $curso->update();
     header("location: ../view/index.php");
 }