forked from joefreeman/dbdiff
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.php
More file actions
Latest commit
47 lines (44 loc) · 1.49 KB
/
Copy pathcli.php
File metadata and controls
47 lines (44 loc) · 1.49 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
36
37
38
39
40
41
42
43
44
45
46
47
<?php
error_reporting(E_ALL);
require_once('DbDiff.php');
require('config.php');
$DbDiff = newDbDiff;
$schema1 = array();
$schema2 = array();
if(isset($argv[1]) && isset($argv[2])){
foreach($dbs_configas$key => $config){
if($config['name'] == $argv[1]){
$schema1 = $config;
}
if($config['name'] == $argv[2]){
$schema2 = $config;
}
}
if(count($schema1) < 1){
echo"Database: $argv[1] not found\n";
exit;
}
if(count($schema2) < 1){
echo"Database: $argv[2] not found\n";
exit;
}
}else{
echo"Usage: \n";
echo"php ".$_SERVER['SCRIPT_NAME']." database1 database2\n";
echo"where database1 and database2 is the name of database in config.php \n";
exit;
}
$result_schema1 = $DbDiff->export($schema1['config'], $schema1['name']);
$result_schema2 = $DbDiff->export($schema2['config'], $schema2['name']);
$result = $DbDiff->compare($result_schema1, $result_schema2);
foreach($resultas$table => $diffs){
echo"\nTable \033[31m".$table."\033[0m\n";
foreach($diffsas$diff){
$diff = str_replace("<code>","\033[31m",$diff);
$diff = str_replace("</code>","\033[0m",$diff);
$diff = str_replace("<em>","",$diff);
$diff = str_replace("</em>","",$diff);
echo$diff."\n";
}
}
?>