-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest.php
More file actions
36 lines (22 loc) · 1.09 KB
/
test.php
File metadata and controls
36 lines (22 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
error_reporting(E_ALL);
include __DIR__.'/MysqlStructSync.php';
function p($arr)
{
echo '<pre>' . print_r($arr, true) . '</pre>';
}
$local_database_config=['host'=>'127.0.0.1','username'=>'root','passwd'=>'root','dbname'=>'old_database','port'=>3306];
$develop_database_config=['host'=>'127.0.0.1','username'=>'root','passwd'=>'root','dbname'=>'develop_database','port'=>3306];
//把local数据库结构更新为develop数据库结构
$compare=new \DDZH\MysqlStructSync($local_database_config,$develop_database_config);
$compare->removeAutoIncrement();
$compare->baseDiff(); //TABLE COLUMNS(ADD,DROP,MODIFY) CONSTRAINTS(PK,FK,index, ... etc)
$compare->advanceDiff(); //VIEW TRIGGER EVENT FUNCTION PROCEDURE (ADD,DROP)
$diff_sql=$compare->getDiffSql();
//p($diff_sql);
/*******************************************/
//用法一:自动执行全部差异语句,更新结构
//$execute_sql_stat=$compare->execute();
//p($execute_sql_stat);
//用法二:手动选择要执行的差异语句,记住:选择储存过程,函数等请确保数据库表已经同步
$compare->manuallySelectUpdates();