Answer the question
In order to leave comments, you need to log in
How to use variable as column name?
There is a function that should check if the user has rights. If there is a right - in cell 1, if not - 0.
func checkIfGroupHasRight(db *sql.DB, groupname interface{}, privilege string) bool {
...
rows, err := db.Query("SELECT ? FROM hellgate_groups WHERE groupname=?", privilege, strGroupname)
...
}
checkIfGroupHasRight(db, session.Values["usergroup"], "deleteuser")
error: "sql: Scan error on column index 0, name \"?\": converting driver.Value type []uint8 (\"deleteuser\") to a int: invalid syntax"
Answer the question
In order to leave comments, you need to log in
no way. placeholders in requests only values are passed
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question