libfic: add new functions to retrieve the Id of some contents from Title, Label, ...
This commit is contained in:
parent
fbae34ee4f
commit
698c2f1a47
4 changed files with 30 additions and 0 deletions
|
|
@ -47,6 +47,17 @@ func GetHint(id int64) (EHint, error) {
|
|||
return h, nil
|
||||
}
|
||||
|
||||
// GetHintByTitle retrieves the hint with the given id.
|
||||
func (e Exercice) GetHintByTitle(id int64) (EHint, error) {
|
||||
var h EHint
|
||||
if err := DBQueryRow("SELECT id_hint, id_exercice, title, content, cost FROM exercice_hints WHERE title = ? AND id_exercice = ?", id, e.Id).Scan(&h.Id, &h.IdExercice, &h.Title, &h.Content, &h.Cost); err != nil {
|
||||
return h, err
|
||||
}
|
||||
treatHintContent(&h)
|
||||
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// GetHints returns a list of hints comming with the challenge.
|
||||
func (e Exercice) GetHints() ([]EHint, error) {
|
||||
if rows, err := DBQuery("SELECT id_hint, title, content, cost FROM exercice_hints WHERE id_exercice = ?", e.Id); err != nil {
|
||||
|
|
|
|||
Reference in a new issue