libfic: new function to get theme by name

This commit is contained in:
nemunaire 2017-12-08 21:03:50 +01:00
parent 8f7de926d3
commit 38606f28c7

View File

@ -41,6 +41,15 @@ func GetTheme(id int) (Theme, error) {
return t, nil
}
func GetThemeByName(name string) (Theme, error) {
var t Theme
if err := DBQueryRow("SELECT id_theme, name, authors FROM themes WHERE name=?", name).Scan(&t.Id, &t.Name, &t.Authors); err != nil {
return t, err
}
return t, nil
}
func CreateTheme(name string, authors string) (Theme, error) {
if res, err := DBExec("INSERT INTO themes (name, authors) VALUES (?, ?)", name, authors); err != nil {
return Theme{}, err