예제 #1
0
func (d *database) InsertComment(c *Comment) error {
	c.CreatedAt = time.Now().Unix()
	c.ID = gox.NewID()
	err := d.insertComment(c)
	if err != nil {
		err = d.insertComment(c)
	}
	return err
}
예제 #2
0
func (d *database) Insert(userID gox.ID, n *Notice) error {
	n.ID = gox.NewID()
	n.NewCount = 1
	n.TotalCount = 1
	n.UpdatedAt = time.Now().Unix()
	_, err := gox.ExecSQL(d.DB, "insert into notices("+noticeFields+
		") values(?,?,?,?,?,?,?,?,?) on duplicate key update total_count=total_count+1, new_count=new_count+1",
		n.ID, userID, n.Type, n.ContentID, gox.JSONMarshalStr(n.Content), n.Title, n.TotalCount, n.NewCount, n.UpdatedAt)
	return err
}
예제 #3
0
파일: db_topics.go 프로젝트: justintan/bbs
func (d *database) InsertTopic(t *Topic) error {
	t.CreatedAt = time.Now().Unix()
	t.CommentedAt = t.CreatedAt
	t.ID = gox.NewID()
	_, err := gox.ExecSQL(d.DB,
		"insert into topics ("+topicFields+") values(?,?,?,?,?,?,?,?,?,?,?,?,?)",
		t.ID, t.UserID, t.ChannelID, gox.JSONMarshalStr(t.Content), t.CreatedAt, t.CommentedAt, t.Status,
		gox.JSONMarshalStr(t.Types), gox.JSONMarshalStr(t.Tags), gox.JSONMarshalStr(t.AtUserIDs),
		t.Location, t.Lat, t.Lng)
	return err
}