golang stmt.Exec 语句怎么返回生成的id

编辑整理:
老秦
热度:
4332

golangstmt.Exec语句怎么返回生成的id

golang 怎么返回生成的ideeb

//数据,这部分只是演示4933111

sqlStr := " into " + saveTableMovie + " (article_title,article_content) value (?,?)"72f65aa

stmt, err := dbw.Db.Prepare(sqlStr)2cc108

defer stmt.Close()31bdc6

res, err := stmt.Exec(Title, Content)b95


//获取id,主要是调取res.LastId()b95

LastId,err := res.LastId()eeb

fmt.Println("新增数据 LastId:", LastId)72f65aa


0b1cd


b95www.9lyp.com