change title db syntax

This commit is contained in:
wish
2022-08-11 18:47:50 +10:00
parent 9fe1b1d04a
commit a0dbe9d8c6

View File

@@ -329,8 +329,9 @@ func handleMsgMhfEnumerateTitle(s *Session, p mhfpacket.MHFPacket) {
func handleMsgMhfAcquireTitle(s *Session, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfAcquireTitle)
err := s.server.db.QueryRow("SELECT count(*) FROM titles WHERE id=$1 AND char_id=$2", pkt.TitleID, s.charID)
if err != nil {
var exists int
err := s.server.db.QueryRow("SELECT count(*) FROM titles WHERE id=$1 AND char_id=$2", pkt.TitleID, s.charID).Scan(&exists)
if err != nil || exists == 0 {
s.server.db.Exec("INSERT INTO titles VALUES ($1, $2, now(), now())", pkt.TitleID, s.charID)
} else {
s.server.db.Exec("UPDATE titles SET updated_at=now()")