I want to give users the functionality of export data from one WordPress plugin installation from one site to another. A "WordPress plugin" doesn’t make the difference, I’m interested in the recommended approach to export/import data in a PHP application that has the data stored in a MySql database. The data is related to each other in the database.
I’m interested in:
- Which is the recommended format to store the data in the exported file (JSON, Xml, serialized)? Taking into care that the data is related to each other by fields in each of the MySql tables, and that can be very big.
Example:
The student table has an ID, Name, and Class_ID…
The class table has an ID, Description…
- Which are the recommendations to avoid specific users problems with hosting configurations that could affect the exporting or importing of large amount of data?
Example: the execution time, the max files size, the max allowed database queries
Important take into care that destination system could have already data that have the same values in the fields declared as keys, for example:
I export the Class with
ID = 5, and Description = "This is cool class"
and in the destination database could be already the Class with:
ID = 5, and Description = "This is other old class"
Where ID is the primary key in "Class" table.
Any idea around this will be appreciated.
If some other information is required let me know.
I would suggest you write your data into XML. It means you have to construct the XML on export, and then you have to read the XML file on input. This way, you control the format and you can change how you handle the import between versions of your plugin.
I can add a bit more detail on how to do this, if you need, but it looked like you were just looking for information on the general approaches.