select fot struct

This commit is contained in:
Your Name 2023-09-19 18:23:38 -04:00
parent 7a98c5e3d9
commit 266e16a060
1 changed files with 9 additions and 2 deletions

11
main.go
View File

@ -133,10 +133,17 @@ func Get(username string) (*UserData, bool) {
log.Printf("scsusers.Get: %s", err.Error())
return nil, false
}
q = fmt.Sprintf("select meta_key, meta_value, id from %s_meta where user=%d", c.TablePrefix, u.UserID)
err = c.db.Select(&u.Meta, q)
q = fmt.Sprintf("select meta_key, meta_value, id from %s_meta where user=?", c.TablePrefix)
rows,err:=c.db.Query(q,u.UserID )
if err != nil && err != sql.ErrNoRows {
log.Printf("scsuser.Get: select: %s", err.Error())
return u,false
}
for rows.Next() {
var m metadata
rows.Scan(m.Key,m.Value,m.ID)
u.Meta[m.Key]=m
}
return u, true
}