Skip to content

Instantly share code, notes, and snippets.

@lf-uraku-yuki
Last active October 27, 2018 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lf-uraku-yuki/0967f9efa7e086202a5a486d19dd8ea9 to your computer and use it in GitHub Desktop.
Save lf-uraku-yuki/0967f9efa7e086202a5a486d19dd8ea9 to your computer and use it in GitHub Desktop.
mysql_all_create_tables_for_php
<?php
$con = new mysqli('localhost', 'root', 'pw', 'dbname');
$mysqli_result = $con->query('show tables');
$table_name_array = $mysqli_result->fetch_all(MYSQLI_BOTH);
$mysqli_result = null;
foreach ($table_name_array as $row) {
$mysqli_result = $con->query('show create table ' . $row[0]);
$create_table = $mysqli_result->fetch_array();
echo $create_table[1] . "\r\n\r\n";
$mysqli_result = null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment