Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function connect($db) {
- $host = '127.0.0.1';
- $user = 'root';
- $pass = '';
- $charset = 'utf8mb4';
- $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
- $options = [
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- PDO::ATTR_EMULATE_PREPARES => FALSE,
- ];
- try {
- $pdo = new PDO($dsn, $user, $pass, $options);
- } catch (\PDOException $e) {
- throw new \PDOException($e->getMessage(), (int) $e->getCode());
- }
- return $pdo;
- }
- function tables($pdo, $database_name) {
- $stmt = $pdo->query("select table_name from information_schema.tables where table_schema = '" . $database_name . "'" );
- while ($row = $stmt->fetch()) {
- $tables[] = $row['table_name'];
- }
- return $tables;
- }
- function count_rows($pdo, $table_name){
- $stmt = $pdo->query('SELECT count(*) as count FROM ' . $table_name);
- return $stmt->fetch()['count'];
- }
- $local_preprod = connect('local_preprod');
- $preprod = connect('preprod');
- $information_schema = connect('information_schema');
- $local_preprod_tables = tables($information_schema, 'local_preprod');
- $preprod_tables = tables($information_schema, 'preprod');
- $local_preprod_tables_counted = [];
- foreach ($local_preprod_tables as $table){
- $local_preprod_tables_counted[$table] = count_rows($local_preprod, $table);
- }
- $preprod_tables_counted = [];
- foreach ($preprod_tables as $table){
- $preprod_tables_counted[$table] = count_rows($preprod, $table);
- }
- foreach ($local_preprod_tables_counted as $key => $value) {
- if (key_exists($key, $preprod_tables_counted) && ($value != $preprod_tables_counted[$key])) {
- print_r('table : ' . $key . ' local_preprod ' . $value . ' preprod ' . $preprod_tables_counted[$key] . "\n");
- }
- }
- var_dump($local_preprod_tables_counted['node__field_occupation_synonym']);
- var_dump($preprod_tables_counted['node__field_occupation_synonym']);
- //var_dump(count($local_preprod_tables));
- //var_dump(count($preprod_tables));
- //var_dump(array_diff($local_preprod_tables, $preprod_tables));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement