u
This commit is contained in:
1 parent
d1b1aafc57
commit
0f1604c709
58 files changed
+15476
-25
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -12,13 +11,10 @@ func (c *Client) QueryRows(query string, args ...any) ([]map[string]any, error)
|
||||
|
||||
rows, err := c.Conn.Query(query, args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, err // 不加 debug.Stack()
|
||||
}
|
||||
defer func(rows *sql.Rows) {
|
||||
_ = rows.Close()
|
||||
}(rows)
|
||||
defer rows.Close()
|
||||
|
||||
// 获取列名
|
||||
columns, err := rows.Columns()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -26,7 +22,6 @@ func (c *Client) QueryRows(query string, args ...any) ([]map[string]any, error)
|
||||
|
||||
results := make([]map[string]any, 0)
|
||||
for rows.Next() {
|
||||
// 为每列创建一个接口值的 slice
|
||||
values := make([]any, len(columns))
|
||||
valuePtrs := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
|
||||
Reference in new issue
Block a user