2

I inherited a forum, that I plan now to move from a very old home-written php version to phpBB. I would like to keep the forum structure, posts and users, so keeping a few tables should be enough. But bringing the content from the old tables to the new structure of the phpBB tables is a bit challenging.

At first I tried with phpMyAdmin, making a copy of my old users table, rearranging the columns so that they all match the new phpBB3_users table structure, manually re-created each additional column that my old table didn't have, and exported it. Then I attempted to import it into the phpBB table. But after around 10 hours or trial an error, I can't get around the following error: #1062 - Duplicate entry '3' for key 'PRIMARY'

My PRIMARY is user_id, and I checked several dozen times, and there are not duplicate entries.

I uploaded the tables to my Google Drive, in case that helps:

- New phpBB3 table

- Old manually corrected table

What am I doing wrong? Should I not try to import the table into the new table, but run a different query?

As you can tell, I know close to nothing about SQL, so any help is appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
FrK
  • 129
  • 4
  • 1
    Is user_id numeric? If not, be aware of the Equal operator and trailing spaces. They are not all the same. See http://stackoverflow.com/a/28682838/1662973 – Anthony Horne Feb 27 '15 at 08:45
  • If you remove the number 3 record and try to import it again, what is the error that you get? Have you done a select * on your database since you first started to try and import data? You should do this to check that half the data hasn't imported and an error hasn't been encountered half way through the initial import. – hlh3406 Feb 27 '15 at 08:56
  • It may cause duplicates in your "import" data. – Anthony Horne Feb 27 '15 at 08:57
  • Anthony, it is numeric. It's a MEDIUMINT value. And to Hollie, I tried that, I still get the same error. I tried up to 20+ consecutive times, and it just keeps popping up. I'm willing to lose some users who will have to re-register, but it still doesn't work. – FrK Feb 27 '15 at 16:15

1 Answers1

0

I'd strongly advise against doing a SQL-only conversion. There are many computed values which phpBB maintains in the database and related entities you might not think of.

Your safest and straightforward option is to use the PHP API methods https://wiki.phpbb.com/Category:API. It's the same methods phpBB uses when a user registers, posts, etc.

Just create your own PHP script, load data from your old table and using these methods, add the entities to phpBB, making sure the core methods take care of any dependencies.

vvondra
  • 3,022
  • 1
  • 21
  • 34