Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function checkTable($table, $connector) {
- $q = "SELECT * FROM `$table` LIMIT 100";
- $rows = $connector->query($q)->fetchAll();
- $rows = array_map(function($row){
- return implode($row, '::');
- }, $rows);
- $rows = implode($rows, PHP_EOL);
- return sha1($rows);
- }
- function checkDB($db, $connector1, $connector2) {
- $connector1->query("USE {$db}");
- $connector2->query("USE {$db}");
- $tables = $connector1->query("SHOW TABLES")->fetchAll(PDO::FETCH_OBJ);
- printf("%20s: %d tables found".PHP_EOL, $db, count($tables));
- foreach($tables as $table) {
- $table = $table->{"Tables_in_$db"};
- $hash1 = checkTable($table, $connector1);
- $hash2 = checkTable($table, $connector2);
- printf("%20s: %50s = %s %s [ %s ]".PHP_EOL, $db, $table, $hash1, $hash2, $hash1 === $hash2 ? 'OK' : 'ER');
- }
- }
- $user = '----';
- $pass = '----';
- $db1 = new PDO('mysql:host=<HOST>', $user, $pass);
- $db2 = new PDO('mysql:host=<HOST>;', $user, $pass);
- // $db2 = new PDO('mysql:host=<HOST>;', $user, $pass);
- $stm = $db1->query("SHOW DATABASES");
- $databases = $stm->fetchAll(PDO::FETCH_OBJ);
- $skipDBS = ['information_schema'];
- foreach ($databases as $db) {
- if (in_array($db->Database, $skipDBS)) continue;
- checkDB($db->Database, $db1, $db2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement