PDA

View Full Version : BaseGuildManager::DBSetGuild()


c0ncrete
07-18-2010, 08:24 PM
Using quest::SetGuild() to change a character's guild ends up putting them in multiple guilds. From what I understand, this is because DBSetGuild() uses 'REPLACE INTO' in the query and the guild_members table doesn't have a PRIMARY KEY or UNIQUE index.

This is from the MySQL reference manual on REPLACE INTO:
Note that unless the table has a PRIMARY KEY or UNIQUE index, using a REPLACE statement makes no sense. It becomes equivalent to INSERT, because there is no index to be used to determine whether a new row duplicates another.

c0ncrete
07-18-2010, 08:37 PM
This fixes the issue:

ALTER TABLE `guild_members` ADD UNIQUE INDEX `char_id`(`char_id`);