chatasos wrote: Hi belzecue2,
I think i cannot quite understand you problem.
You said that you applied replication to your db and that all auto-increment values were changed to random values. If this is the default behaviour of msaccess replication, shouldn't all other phpbb tables (posts, topics, etc.) have problems too? Many phpbb tables use auto-increment values.
When you convert an Access db for replication, all 'autoincrement' fields get altered to 'random' values. Example values for an insert to a random datatype field are: 1423244298, -867554, -127854567, 43556 etc. When converting the original db, Access is smart enough to work out what foreign key values it needs to change. Having a relational table mapping probably helps. My PHPBB has been running without problems since I converted the original msaccess db for 2.0.18.
In your code, you assume the minimum 'start_post_id' is 1. Because the post_id in a replicated msaccess post table is a random value (signed large integer), the first record in the table is of course not going to be 1. Nor is the last post in the table going to be the current max post_id. The sequence could be that one from the previous paragraph.
For a post_id field with a random datatype, you would need to process the whole table from first record to last record, not rely on the post_ids being sequential, and not assume the logic of first post_id = 1 and last post_id = max(post_id).
Of course, this makes multiple incremental rebuild passes impossible -- when ending at post_id X, you can't tell the rebuild process to restart at post_id X+1 because in this case post_id is *not* in sequencial order.
This is a very unique case (having a replicated msaccess db) so I don't think you should waste time modifying your code to cope with it. Eventually, my db will be upsized to sqlserver and the post_id and other affected columns will be converted back to identity/autoincrement. Then I'll be able to use your excellent mod!