libfic: add new functions to retrieve the Id of some contents from Title, Label, ...

This commit is contained in:
nemunaire 2019-11-25 14:19:29 +01:00
commit 698c2f1a47
4 changed files with 30 additions and 0 deletions

View file

@ -127,6 +127,15 @@ func (k FlagKey) GetId() int64 {
return k.Id
}
// RecoverId returns the Flag identifier as register in DB.
func (k FlagKey) RecoverId() (Flag, error) {
if err := DBQueryRow("SELECT id_flag FROM exercice_flags WHERE type LIKE ? AND id_exercice = ?", k.Label, k.IdExercice).Scan(&k.Id); err != nil {
return FlagKey{}, err
} else {
return k, err
}
}
// AddFlagKey creates and fills a new struct Flag, from a hashed flag, and registers it into the database.
func (k FlagKey) Create(e Exercice) (Flag, error) {
// Check the regexp compile