Ciao, sto realizzando un'interfaccia che tramite php si collega ad un db MYSQL esistente.
Ora, ho un dubbio, nel db ho trovato questa tabella:
In cui alcuni campi, fra cui guid sono messi come chiavi primarie.Codice PHP:CREATE TABLE `character_inventory` (
`guid` bigint(20) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
`bag` bigint(20) unsigned NOT NULL default '0',
`slot` tinyint(3) unsigned NOT NULL default '0',
`item` bigint(20) unsigned NOT NULL default '0' COMMENT 'Item Global Unique Identifier',
`item_template` int(11) unsigned NOT NULL default '0' COMMENT 'Item Identifier',
PRIMARY KEY (`guid`,`bag`,`slot`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Player System';
Il problema è che il contenuto della tabella, specialmente nel campo guid contiene chiavi identiche:
Com'è possibile? Le chiavi non dovrebbero essere diverse le une dalle altre in un campo primary?codice:guid bag slot ... ....... 2 255 6 16 22417 2 255 5 26 22422 2 255 4 14 22416 2 255 2 20 22419 4 255 30 40 6120 4 255 29 44 2362 4 255 28 42 6122
Se faccio un insert ottengo giustamente un errore di chiave duplicata.
So che si può usare IGNORE, ma non è comunque un uso sbagliato di primary?
Grazie per l'attenzione!

Rispondi quotando

