func SearchCourses(moodleid int) ([]Course, error) {
	var result []Course
	// Get the connection
	connection, err := db.GetDB()
	if err != nil {
		return result, err
	}

	// Query the DB
	rows, err := connection.Query(`
		SELECT id, shortname, fullname, summary, downloaded, showgrades, previoushash, unhandlednotifications, newcourse, deletedcourse
		FROM courses
		WHERE moodleid=?
	`, moodleid)
	if err != nil {
		return result, err
	}

	defer rows.Close()

	// Get and save to the struct
	for rows.Next() {
		var c Course
		err = rows.Scan(
			&c.ID,
			&c.Shortname,
			&c.Fullname,
			&c.Summary,
			&c.Downloaded,
			&c.Showgrades,
			&c.Previoushash,
			&c.Unhandlednotifications,
			&c.Newcourse,
			&c.Deletedcourse)
		if err != nil {
			return result, err
		}
		result = append(result, c)
	}

	return result, err
}
// SearchCourses returns all the courses that exist locally
SearchCourses returns all the courses that exist locally
// SearchCourses returns all the courses that exist locally
func SearchCourses(moodleid int) ([]Course, error) {
	var result []Course
	connection, err := db.GetDB()
	if err != nil {
		return result, err
	}
	rows, err := connection.Query(`
		SELECT id, shortname, fullname, summary, downloaded, showgrades, previoushash, unhandlednotifications, newcourse, deletedcourse
		FROM courses
		WHERE moodleid=?
	`, moodleid)
	if err != nil {
		return result, err
	}
	defer rows.Close()
	for rows.Next() {
		var c Course
		err = rows.Scan(
			&c.ID,
			&c.Shortname,
			&c.Fullname,
			&c.Summary,
			&c.Downloaded,
			&c.Showgrades,
			&c.Previoushash,
			&c.Unhandlednotifications,
			&c.Newcourse,
			&c.Deletedcourse)
		if err != nil {
			return result, err
		}
		result = append(result, c)
	}
	return result, err
}
func SearchCourses ( moodleid int ) ( [ ] Course , error ) { var result [ ] Course connection , err := db . GetDB ( ) if err != nil { return result , err } rows , err := connection . Query ( `
		SELECT id, shortname, fullname, summary, downloaded, showgrades, previoushash, unhandlednotifications, newcourse, deletedcourse
		FROM courses
		WHERE moodleid=?
	` , moodleid ) if err != nil { return result , err } defer rows . Close ( ) for rows . Next ( ) { var c Course err = rows . Scan ( & c . ID , & c . Shortname , & c . Fullname , & c . Summary , & c . Downloaded , & c . Showgrades , & c . Previoushash , & c . Unhandlednotifications , & c . Newcourse , & c . Deletedcourse ) if err != nil { return result , err } result = append ( result , c ) } return result , err }
SearchCourses returns all the courses that exist locally
SearchCourses returns all the courses that exist locally
// Get the connection // Query the DB // Get and save to the struct