libfic: add function to get exercice by title
This commit is contained in:
parent
f97e114a81
commit
38d7cb00b6
1 changed files with 9 additions and 0 deletions
|
@ -36,6 +36,15 @@ func (t Theme) GetExercice(id int) (Exercice, error) {
|
||||||
return e, nil
|
return e, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t Theme) GetExerciceByTitle(title string) (Exercice, error) {
|
||||||
|
var e Exercice
|
||||||
|
if err := DBQueryRow("SELECT id_exercice, title, path, statement, depend, gain, coefficient_cur, video_uri FROM exercices WHERE id_theme = ? AND title = ?", t.Id, title).Scan(&e.Id, &e.Title, &e.Path, &e.Statement, &e.Depend, &e.Gain, &e.Coefficient, &e.VideoURI); err != nil {
|
||||||
|
return Exercice{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return e, nil
|
||||||
|
}
|
||||||
|
|
||||||
func GetExercices() ([]Exercice, error) {
|
func GetExercices() ([]Exercice, error) {
|
||||||
if rows, err := DBQuery("SELECT id_exercice, title, path, statement, depend, gain, coefficient_cur, video_uri FROM exercices"); err != nil {
|
if rows, err := DBQuery("SELECT id_exercice, title, path, statement, depend, gain, coefficient_cur, video_uri FROM exercices"); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Reference in a new issue