Create DB Table from .SQL (dump) file

Not a really complex thing, but something that comes in handy if you’re moving data around and need to quickly create MySQL db tables through PHP.

 

 

 Pretty simple to use.  Just place the function at the top of your page (or at least somewhere higher up the file than when you call it) and give it the name (path included) to the .sql file. 

Something like:

create_table(“path_to_file/dump.sql”);

Creates tables with or without data.  Simply takes whatever kind of sql dump you give it and re-creates the database or table it came from.

Enjoy.

Leave a Reply

Your email address will not be published. Required fields are marked *