sql错误
This commit is contained in:
parent
7e1d876604
commit
8165233396
19
dao/shell.go
19
dao/shell.go
|
|
@ -77,9 +77,24 @@ func UpdateShellByID(id, authId uint, shellName, shellContent string, status int
|
|||
func FindShellWillRunByServer(server string, uid uint) []Shell {
|
||||
var shells []Shell
|
||||
if proto.Config.SERVER_SQL_LOG {
|
||||
DB.Debug().Exec("select * from shells where server = ? and auth_id = ? and status = 0 order by created_at desc limit 100", server, uid).Scan(&shells)
|
||||
result := DB.Debug().Where("server = ? AND auth_id = ? AND status = 0", server, uid).
|
||||
Order("created_at DESC").
|
||||
Limit(100).
|
||||
Find(&shells)
|
||||
if result.Error != nil {
|
||||
// 若查询过程中出现错误,输出错误信息
|
||||
log.Printf("Failed to query shells: %v\n", result.Error)
|
||||
}
|
||||
} else {
|
||||
DB.Exec("select * from shells where server = ? and auth_id = ? and status = 0 order by created_at desc limit 100", server, uid).Scan(&shells)
|
||||
//DB.Exec("select * from shells where server = ? and auth_id = ? and status = 0 order by created_at desc limit 100", server, uid).Scan(&shells)
|
||||
result := DB.Where("server = ? AND auth_id = ? AND status = 0", server, uid).
|
||||
Order("created_at DESC").
|
||||
Limit(100).
|
||||
Find(&shells)
|
||||
if result.Error != nil {
|
||||
// 若查询过程中出现错误,输出错误信息
|
||||
log.Printf("Failed to query shells: %v\n", result.Error)
|
||||
}
|
||||
}
|
||||
return shells
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue