summaryrefslogtreecommitdiffstats
path: root/cli.php
diff options
context:
space:
mode:
authorJoe Freeman <joe.freeman@bitroot.com>2016-05-10 17:13:02 +0100
committerJoe Freeman <joe.freeman@bitroot.com>2016-05-10 17:13:02 +0100
commit36c438e3cbc6fe08ab73cafb2ac1d4bfa1a6d83b (patch)
tree90fb79fee79a66b67ea5f8286b6c411ab7eb2ab2 /cli.php
parent7af44552fb46a40a908a76d2850134843605e2ea (diff)
parent9d0a1361beaf3271575ed687a65335f31189103e (diff)
downloaddbdiff-master.zip
dbdiff-master.tar.gz
dbdiff-master.tar.bz2
Merge pull request #3 from flammy/masterHEADorigin/masterorigin/HEADmaster
Create cli.php
Diffstat (limited to 'cli.php')
-rw-r--r--cli.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/cli.php b/cli.php
new file mode 100644
index 0000000..d571702
--- /dev/null
+++ b/cli.php
@@ -0,0 +1,47 @@
+<?php
+error_reporting(E_ALL);
+require_once('DbDiff.php');
+require('config.php');
+$DbDiff = new DbDiff;
+$schema1 = array();
+$schema2 = array();
+if(isset($argv[1]) && isset($argv[2])){
+ foreach($dbs_config as $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($result as $table => $diffs){
+ echo "\nTable \033[31m".$table."\033[0m\n";
+ foreach($diffs as $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";
+ }
+}
+?>