我想使用以下命令获取插入MySql数据库的最后一个帖子的ID sqlx
:
resultPost, err := shared.Dbmap.Exec("INSERT INTO post (user_id, description, link) VALUES (?, ?, ?)", userID, title, destPath)
if err != nil {
log.Println(err)
c.JSON(
http.StatusInternalServerError,
gin.H{"error": "internal server error"})
}
fmt.Println("resultPost is:", resultPost)
问题是将resultPost
列印为物件:
resultPost is: {0xc420242000 0xc4202403a0}
因此,我想知道提取刚刚插入的行的ID的正确方法是什么?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句