type Stmt
type Stmt如下表所示。
方法 | 描述 | 返回值 |
(s *Stmt)Close() | 关闭给定的预处理语句。 | error |
(s *Stmt)Exec(args ...interface{}) | 使用给定的参数执行预处理语句,并返回一个Result值。 | Result, error |
(s *Stmt)ExecContext(ctx context.Context, args ...interface{}) | 在给定的上下文中,使用给定的参数执行预处理语句,并返回一个Result值。 | Result, error |
(s *Stmt)Query(args ...interface{}) | 使用给定的参数执行预处理语句,并以*Rows形式返回查询结果。 | *Rows, error |
(s *Stmt)QueryContext(ctx context.Context, args ...interface{}) | 在给定的上下文中,使用给定的参数执行预处理语句,并以*Rows形式返回查询结果。 | *Rows, error |
(s *Stmt)QueryRow(args ...interface{}) | 使用给定的参数执行预处理语句,并返回一个*Row作为结果。 | *Row |
(s *Stmt)QueryRowContext (ctx context.Context, args ...interface{}) | 在给定的上下文中,使用给定的参数执行预处理语句,并返回一个*Row作为结果。 | *Row |
参数说明
参数 | 参数说明 |
ctx | 表示给定的上下文。 |
query | 被执行的sql语句。 |
args | 被执行sql语句需要绑定的参数。支持按位置绑定和按名称绑定,详情DB类型中的示例。 |

