I am trying to get quite a complex insert to work, im not sure if its even feasible. We have about 35 tables but ill just put an example down below then ill explain what needs doing.



Basically what we(my team, 2nd year comp sci group) are trying to do is duplicate the data in the tables changing the models_ID to a new value. The whole system works on a year by year basis and the clients want to duplicate the data year on year, which is what the models_ID represents. This is fine, importing like that is ok. Now where our problem lies is that when we duplicate the duties data, changing the models_ID to the new one we also change its ID as this is set as auto increment. Now as dutieusers relies on this in its table when we duplicate all the dutieusers the duties_ID match up to the old duties.

We cannot figure out how to do the import and keep those ID's matched up. Our current approach is to loop through all the data in PHP as objects using nested for each loops and so we have direct access to them. This is painfully slow with plenty of data and all the tables as well as a memory hog. Any help will be appreciated. Thanks,