func (controller *Program) loadProgram() { ID := controller.Ctx.Input.Param(":program") program, err := repository.NewProgram(ID) if err == nil { controller.Data["program"] = program controller.program = program } }
// gets the programs func (search ProgramSearch) getFromDB() []repository.Program { var list []repository.Program limitClause := search.options.GetLimit() fieldsList := "`id`" whereClause := "WHERE `title` LIKE ? OR `code` LIKE ?" sql := "SELECT DISTINCT " + fieldsList + " FROM `institution_program` " + whereClause + space + limitClause rows, err := database.Connection.Query(sql, search.likeQuery(), search.likeQuery()) if err != nil { fmt.Println(err) } for rows.Next() { programID := "" rows.Scan(&programID) item, _ := repository.NewProgram(programID) list = append(list, item) } return list }