:= m.Conn.Begin()
if err != nil {
log.Fatal(err)
}
query := INSERT user SET usr_username=? , usr_first_name=? , usr_last_name=?,usr_password = ?,usr_create_time = ?
stmt, err := m.Conn.Prepare(query)
if err != nil {
logrus(err)
return 0, err
}
res, err := stmt.Exec(user.Username, user.Firstname, user.Lastname, user.Password, int32(time.Now().Unix()))
if err != nil {
tx.Rollback()
logrus(err)
return 0, err
}
query2 := INSERT user SET usrb_usr_id=? , usrb_balance=? , usrb_create_time=?
stmt, err := m.Conn.Prepare(query2)
if err != nil {
logrus(err)
return 0, err
}
res, err := stmt.Exec(user.ID, 0, int32(time.Now().Unix()))
if err != nil {
tx.Rollback()
logrus(err)
return 0, err
}
defer stmt.Close()
tx.Commit()
return res.LastInsertId()
}
Please format the code you posted, by wrapping it in triple backticks. -> `
Обсуждают сегодня