extend.go 469 B

12345678910111213141516171819202122
  1. package like
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/pkg/errors"
  6. )
  7. const (
  8. _addLikeExtendSQL = "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(_addLikeExtendSQL, query))
  13. if err != nil {
  14. err = errors.Wrap(err, " dao.db.Exec()")
  15. return
  16. }
  17. return rows.RowsAffected()
  18. }