This commit is contained in:
@@ -365,10 +365,20 @@ func UserGetSafesAllowed(userId int) ([]UserSafe, error) {
|
||||
INNER JOIN permissions ON groups.GroupId = permissions.GroupId
|
||||
INNER JOIN safes on permissions.SafeId = safes.SafeId
|
||||
WHERE users.UserId=?`, userId)
|
||||
defer rows.Close()
|
||||
|
||||
if err != nil {
|
||||
log.Printf("UserGetSafesAllowed error executing sql record : '%s'\n", err)
|
||||
return results, err
|
||||
} else {
|
||||
|
||||
// Get columns from rows for debugging
|
||||
columns, err := rows.Columns()
|
||||
if err != nil {
|
||||
log.Printf("UserGetSafesAllowed error getting column listing : '%s'\n", err)
|
||||
return results, err
|
||||
}
|
||||
|
||||
// parse all the results into a slice
|
||||
for rows.Next() {
|
||||
var us UserSafe
|
||||
@@ -383,6 +393,22 @@ func UserGetSafesAllowed(userId int) ([]UserSafe, error) {
|
||||
|
||||
results = append(results, us)
|
||||
|
||||
// Create a map to store column names and values
|
||||
rowValues := make(map[string]interface{})
|
||||
|
||||
// Scan each row into the map
|
||||
err := rows.MapScan(rowValues)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
|
||||
// Print the raw row record
|
||||
for _, column := range columns {
|
||||
fmt.Printf("%s: %v\n", column, rowValues[column])
|
||||
}
|
||||
fmt.Println("-----------")
|
||||
|
||||
}
|
||||
log.Printf("UserGetSafesAllowed retrieved '%d' results\n", len(results))
|
||||
}
|
||||
|
Reference in New Issue
Block a user