Hi, i'm using php and mysql for a webpage, and i want to reuse information which i have in three database tables, similar to a 'save as' operation.
The tables are related as a 1-many and then 1-many, a tree structure.
I have so far implemented it by flatten out the tree structure with php (similar to one giant table) and storing it in an array. Then looped over every row, and even every part of the row, and for each one inserted into the corresponding table with a query. It sort of works, but with a lot of code to see if every post even has the information from the third table (it could be empty).
Now, my question is, could this be implemented in a more efficient way? There could be a lot of queries to the database this way.
The problem here seems to be how to relate the new posts. I have looked at 'SELECT INTO', but as i need to relate the new keys, i don't see how it could work. Also, mysql_insert_id only give me the latest id, not all of them.