update stmt

master
兔子 6 years ago
parent 69ee5f692b
commit 1f2364c172

@ -780,6 +780,8 @@ func FetchAll(rows *sql.Rows) (error, map[int]map[string]string) {
record := make(map[string]string) record := make(map[string]string)
for i, col := range values { for i, col := range values {
switch vtype := col.(type) { switch vtype := col.(type) {
case float64:
record[columns[i]] = strconv.FormatFloat(vtype, 'f', -1, 64)
case int64: case int64:
record[columns[i]] = strconv.FormatInt(vtype, 10) record[columns[i]] = strconv.FormatInt(vtype, 10)
case string: case string:
@ -826,6 +828,7 @@ func Query(args ...interface{}) (error, map[int]map[string]string) {
} }
sql := args[0] sql := args[0]
stmt, err := DBRes.Prepare(sql.(string)) stmt, err := DBRes.Prepare(sql.(string))
defer stmt.Close()
if err != nil { if err != nil {
return err, records return err, records
} }
@ -862,6 +865,7 @@ func DBExec(args ...interface{}) error {
} }
sql := args[0] sql := args[0]
stmt, err := DBRes.Prepare(sql.(string)) stmt, err := DBRes.Prepare(sql.(string))
defer stmt.Close()
if err != nil { if err != nil {
return err return err
} }
@ -1010,7 +1014,7 @@ func MessageBox(text, defaults string) string {
str = str[0 : len(str)-1] str = str[0 : len(str)-1]
} }
if str == "" { if str == "" {
str = defaults str = defaults
} }
return strings.TrimSpace(str) return strings.TrimSpace(str)
} }

Loading…
Cancel
Save