extend.go 460 B

12345678910111213141516171819202122
  1. package like
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/pkg/errors"
  6. )
  7. var (
  8. _batchUpExtSQL = "INSERT INTO like_extend (`lid`,`like`) VALUES %s ON DUPLICATE KEY UPDATE `like`=values(`like`)"
  9. )
  10. // AddExtend .
  11. func (dao *Dao) AddExtend(c context.Context, query string) (res int64, err error) {
  12. rows, err := dao.db.Exec(c, fmt.Sprintf(_batchUpExtSQL, query))
  13. if err != nil {
  14. err = errors.Wrap(err, " dao.db.Exec()")
  15. return
  16. }
  17. return rows.RowsAffected()
  18. }