in reply to
How to display all the content of the database?
Rather than answer the question directly, I'd like to ask some questions about the question.
Display of "all the content of the database" "no matter how deep it goes"? If you want a generic script that recurses through foreign keys to display data, then consider 2 possibilities:
- Your database has a large number of tables with a large number of associations. You will potentially be writing out a massive stream of data. Why would you want to have such a massive file? Either for archiving or for a human to use.
- Is it for a human to look at? How many trees would you sacrifice to print out a sizable chunk of a 5 gig database? How would a human find something in the file? Wouldn't it be better just figuring out what the human wants to know and writing some nice queries for them?
- Is it for archiving? Then why not just dump the database (e.g., via mysqldump)?
- Your database is small with a small number of tables. In this case, why not just write a one-off script? You can change it later if you need to rerun it after a change to the schema is made. Trying to conceive of the general case with a recursive search through the data dictionary just seems like it will take alot of time. And recursive code is never the most readable if someone else needs to work with it later. There is a time and place for quick one-off hacks, and this may be one of them.
Although I don't know exactly what it is you are trying to do, my impression is that reanalyzing your initial approach may be fruitful.
Hope this helps :-)