// GetSubject returns the subject area of the program of study func (program Program) GetSubject() *education.Subject { subject, err := education.NewSubject(strconv.Itoa(program.subject)) if err != nil { fmt.Println(err) } return subject }
func (controller *Controller) loadSubject() { ID := controller.Ctx.Input.Param(":subject") subject, err := model.NewSubject(ID) if err != nil { controller.Abort("show-database-error") } controller.Data["subject"] = subject controller.subject = subject controller.SetCustomTitle("Admin - " + subject.GetName()) }
// GetEducationSubjects returns the distinct Subjects func (institution Institution) GetEducationSubjects() []*education.Subject { list := []*education.Subject{} fieldList := "`subject`" whereClause := "WHERE `institution` = ?" sql := "SELECT DISTINCT " + fieldList + " FROM `institution_program` " + whereClause rows, _ := database.Connection.Query(sql, strconv.Itoa(institution.ID)) for rows.Next() { ID := "" rows.Scan(&ID) item, _ := education.NewSubject(ID) list = append(list, item) } return list }
// it gets the subjects from database func (search SubjectSearch) getFromDB() []*education.Subject { var list []*education.Subject limitClause := search.options.GetLimit() fieldsList := "`id`" whereClause := "WHERE `name` LIKE ?" sql := "SELECT DISTINCT " + fieldsList + " FROM `subject_area` " + whereClause + space + limitClause rows, err := database.Connection.Query(sql, search.likeQuery()) if err != nil { fmt.Println(err) } for rows.Next() { var ID string rows.Scan(&ID) item, _ := education.NewSubject(ID) list = append(list, item) } return list }
// GetSubject returns the subject object func (analyser InstitutionAnalyser) GetSubject() *education.Subject { subject, _ := education.NewSubject(analyser.subject) return subject }