Hi David,
Sent this as an email but will post here as well.
Quick question - I have Magicparser as part of Price tapestry - I'm trying
to use the XML -> mySQL DB externally on another site, everything is
working as expected on the import to the database, however I keep getting
duplicate rows of data - I don't get any error messages, everything seems
to insert ok, however when I check the DB I can see two rows of the same
data for each entry.
I've checked the support forums and this seems to indicate a primary key
on the database with auto incrementation, however I have this setup:
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
Would there be anything in the code or Magicparser that would insert the
data twice? I've dropped the table a few times and rebuilt, however I keep
getting the same errors.
Any help is appreciated,
Thanks!
Hi David,
Thanks for that.
I've set the table as instructed, however I now get a duplicate entry error from mySQL when the script tries to insert into the DB, any ideas?
Thanks again!
That would indicate that your script is outputting MySQL error messages - if you remove any code in your custom script that is printing mysql_error() that will suppress the output. Bear in mind in this case it's an intentional error that you are expecting as part of your duplicate prevention process.
The only alternatively is to do a SELECT / INSERT which would be much slower!
Cheers,
David.
--
PriceTapestry.com
Yup seems the mySQL debug had an exit() call if any errors were found, seems to be populating correctly once I remove that portion at least.
Thanks again!
Hi pixelcoder,
It's almost certainly duplication in your source in that case; which is very common affiliate datafeeds and code is built into Price Tapestry to handle this so you probably want to implement something similar with your custom database.
The straight forward way is simply to add a unique key to the table that you are importing into against a key field that you do not wish to be duplicated; for example if you have a `name` field then your table creation SQL could use;
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY name (name),
Cheers,
David.
--
PriceTapestry.com