Scripting out database objects with PHP

I’ve recently needed to script out the create sql for various MySQL database objects. No Powershell or SMO to help with this so I’ve quickly rolled a PHP script to get this done.


This will script out all tables, views, triggers, stored procedures and functions from the specified database. One file per object in your /tmp directory (you’ll need to change this if you’re running on Windows). Just change the $source_host, $source_db, $source_user and $source_pwd variables to point at the database you want to script out.


run_php_create_sql_script.gif
sql_files.gif
generated_sql_for_store_table.gif

Leave a Reply