Commit ea225fe0 authored by Vladimir Barsukov's avatar Vladimir Barsukov
Browse files

RowsAffected

parent 17495ccc
......@@ -3,11 +3,23 @@ package zdb
func (d *Pool) WExec(sql string, args ...any) error {
return d.qExec(d.SrvMaster, sql, args...)
}
func (d *Pool) WExecQty(sql string, args ...any) (int64, error) {
return d.qExecQty(d.SrvMaster, sql, args...)
}
func (d *Pool) WExecNamed(sql string, args map[string]any) error {
newSql, newArgs := d.prepare(sql, args)
return d.qExec(d.SrvMaster, newSql, newArgs...)
}
func (d *Pool) WExecNamedQty(sql string, args map[string]any) (int64, error) {
newSql, newArgs := d.prepare(sql, args)
return d.qExecQty(d.SrvMaster, newSql, newArgs...)
}
func (d *Pool) WExecOpts(opts Opts) error {
sql, args := opts.Opts()
newSql, newArgs := d.prepare(sql, args)
......@@ -15,8 +27,24 @@ func (d *Pool) WExecOpts(opts Opts) error {
return d.qExec(d.SrvMaster, newSql, newArgs...)
}
func (d *Pool) WExecOptsQty(opts Opts) (int64, error) {
sql, args := opts.Opts()
newSql, newArgs := d.prepare(sql, args)
return d.qExecQty(d.SrvMaster, newSql, newArgs...)
}
func (d *Pool) qExec(q *Conn, sql string, args ...any) error {
_, err := q.Exec(d.ctx, sql, args...)
return err
}
func (d *Pool) qExecQty(q *Conn, sql string, args ...any) (int64, error) {
s, err := q.Exec(d.ctx, sql, args...)
if err != nil {
return 0, err
}
return s.RowsAffected(), nil
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment