Skip to content

Commit

Permalink
sql条件查询区分大小写
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Jan 14, 2021
1 parent d94863c commit a767a42
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (mysql *Mysql) CleanDataByName(usernames []string) error {
return errors.New("can't connect mysql")
}
defer db.Close()
runSql := "UPDATE users SET download=0, upload=0 WHERE username in ("
runSql := "UPDATE users SET download=0, upload=0 WHERE BINARY username in ("
for i, name := range usernames {
runSql = runSql + "'" + name + "'"
if i == len(usernames)-1 {
Expand All @@ -339,7 +339,7 @@ func (mysql *Mysql) GetUserByName(name string) *User {
return nil
}
defer db.Close()
user, err := queryUser(db, fmt.Sprintf("SELECT * FROM users WHERE username='%s'", name))
user, err := queryUser(db, fmt.Sprintf("SELECT * FROM users WHERE BINARY username='%s'", name))
if err != nil {
return nil
}
Expand All @@ -353,7 +353,7 @@ func (mysql *Mysql) GetUserByPass(pass string) *User {
return nil
}
defer db.Close()
user, err := queryUser(db, fmt.Sprintf("SELECT * FROM users WHERE passwordShow='%s'", pass))
user, err := queryUser(db, fmt.Sprintf("SELECT * FROM users WHERE BINARY passwordShow='%s'", pass))
if err != nil {
return nil
}
Expand Down

0 comments on commit a767a42

Please sign in to comment.