create.go 499 B

123456789101112131415161718
  1. package yb_comment_anonymous_user
  2. import (
  3. "hongze/hongze_yb/global"
  4. "time"
  5. )
  6. func (item *YbCommentAnonymousUser) Create() (err error) {
  7. err = global.DEFAULT_MYSQL.Model(YbCommentAnonymousUser{}).Create(item).Error
  8. return
  9. }
  10. // CreateBySql 通过sql创建记录
  11. func CreateBySql(userId uint64, createTime time.Time) (err error) {
  12. sql := "INSERT INTO `yb_comment_anonymous_user` (`user_id`,`create_time`) VALUES (?,?)"
  13. err = global.DEFAULT_MYSQL.Exec(sql, userId, createTime).Error
  14. return
  15. }