I need to generate PHP (php >= 5.3) code from MySQL database using PDO.
You will have to use SELECT (...) FROM INFORMATION_SCHEMA (...). More info about INFORMATION_SCHEMA.
The idea is to create a script "[url removed, login to view]" with the following inputs in a form:
and a submit button that will generate files for all the tables and views of the database supplied.
Data access will be made with PDO.
For each table / view, the generator will generate the following files:
- .[url removed, login to view] : Business class
- [url removed, login to view]: Data access functions
- [url removed, login to view]: Rest full services functions (Slim framework. You don't need to know anything about Slim. The code and documentation are quite clear)
There are 3 different cases. For each case, the generator will generate slighty different code:
- For a table with a unique PK. In this case, the PK always is autogenerated.
- For a table with more than one field as PK. In this case, PK fields are NOT autogenerated
- For a view
The files generated by the script, will be saved in the same directory than [url removed, login to view]
If any error occurs (for example, the file output is used and cannot be overwritten), show a error message in [url removed, login to view]
Optional: Meanwhile the generator is working, show progress information in the generator.php.
See attached file "[url removed, login to view]" and other sample files.