Many times, everyone has to "take over the gun from others" and develop and modify the existing code... Therefore, many times, they are not very familiar with the data storage structure. It affects the efficiency of work and wastes a lot of time in consulting the database storage structure. (Of course, except for those who use GUI database tools.)
Because I rely more on the development environment of VIM + mysql client, I wrote a small PHP script to generate the create statements of all tables into a folder at once, and use lists to manage them, so that they can be used in vim Use the gf hotkey to jump to the definition of that table at once, which I personally think is more convenient.
Why not store all statements in the same file? There are several reasons:
1. The Chinese comment encoding format of some tables is incorrect and may be garbled, which may affect the Chinese that appears below;
2. If there is a list file, it will be easier to manage and clear at a glance. I personally like it better, haha.
以下为引用的内容: /** * 用来生成MySQL数据库文档 * @filename mysql_db_creator.php * @touch 2009年 09月 07日 星期一 14:33:47 CST * @author Yufeng Zhang */ define('HOST' , '192.168.1.162'); define('PORT' , 3306); define('USER' , 'zhangyufeng'); define('PASS' , 'zhangyufeng'); define('DB_NAME' , 'beijing'); define('DB_CHARSET' , 'utf8'); //数据表列表文件 define('SAVE_FILE_NAME' , 'ganji_v3_beijing_tables_list'); //详细文档存入路径 define('SAVE_FILE_FOLDER' , 'ganji_v3_beijing'); //定义路径 $path_info = pathinfo(__FILE__); define('DIR_NAME' , $path_info['dirname']); if(!is_dir(DIR_NAME . '/' . SAVE_FILE_FOLDER)){ mkdir(DIR_NAME . '/' . SAVE_FILE_FOLDER); } $mysql_link = mysql_connect(HOST . ':' . PORT , USER, PASS); if(!$mysql_link){ die("Counld not connect to Mysql:n" . mysql_error()); } mysql_query('use ' . DB_NAME); mysql_query('set names ' . DB_CHARSET); $table_resource = mysql_query("SHOW TABLES FROM " . DB_NAME, $mysql_link); if(!$table_resource){ die("Counld not open DB:n" . mysql_error()); } $file_list = "////////////////////////////////////////////n"; $file_list .= "Welcome To Mysql_soup_listn"; $file_list .= "////////////////////////////////////////////n"; $result_soup = ''; while($row = mysql_fetch_row($table_resource)){ $sql = "show create table " . $row[0]; $get_sql = mysql_query($sql , $mysql_link); $result_soup = ''; if($row_table = mysql_fetch_row($get_sql)){ $result_soup .= "//------------------------------------n"; $result_soup .= "//------------------------------------n"; $result_soup .= "// " . $row_table[0] . "n"; $result_soup .= "// " . $row_table[1] . "n"; $file_save = SAVE_FILE_FOLDER . '/' . $row_table[0]; } file_put_contents($file_save, $result_soup); $file_list .= DIR_NAME . '/' . $file_save . "n"; } file_put_contents(SAVE_FILE_NAME , $file_list); mysql_close($mysql_link); |
Have you noticed: The last variable name is result_soup.
Reprinted from: http://www.cnblogs.com/amboyna/