private function compare($source, $destination)
    {
        $this->source_structure = $source;
        $this->destination_structure = $destination;

        $result = [];
        $destTabNames = $this->getTableList($this->destination_structure);
        $sourceTabNames = $this->getTableList($this->source_structure);

        $common = array_intersect($destTabNames, $sourceTabNames);
        $destOrphans = array_diff($destTabNames, $common);
        $sourceOrphans = array_diff($sourceTabNames, $common);
        $all = array_unique(array_merge($destTabNames, $sourceTabNames));
        sort($all);

        foreach ($all as $tab) {
            $info = ['destOrphan' => false, 'sourceOrphan' => false, 'differs' => false];

            if (in_array($tab, $destOrphans)) {
                $info['destOrphan'] = true;
            } elseif (in_array($tab, $sourceOrphans)) {
                $info['sourceOrphan'] = true;
            } else {
                $destinationSql = $this->getTabSql($this->destination_structure, $tab, true);
                $sourceSql = $this->getTabSql($this->source_structure, $tab, true);
                $diffs = $this->compareSql($sourceSql, $destinationSql);

                if ($diffs === false) {
                    trigger_error('[WARNING] error parsing definition of table "' . $tab . '" - skipped');
                    continue;
                } elseif (!empty($diffs)) // not empty array
                {
                    $info['differs'] = $diffs;
                } else continue;//empty array
            }
            $result[$tab] = $info;
        }

        return $result;
    }
private function compare($source, $destination)
    {
        $this->source_structure = $source;
        $this->destination_structure = $destination;

        $result = [];
        $destTabNames = $this->getTableList($this->destination_structure);
        $sourceTabNames = $this->getTableList($this->source_structure);

        $common = array_intersect($destTabNames, $sourceTabNames);
        $destOrphans = array_diff($destTabNames, $common);
        $sourceOrphans = array_diff($sourceTabNames, $common);
        $all = array_unique(array_merge($destTabNames, $sourceTabNames));
        sort($all);

        foreach ($all as $tab) {
            $info = ['destOrphan' => false, 'sourceOrphan' => false, 'differs' => false];

            if (in_array($tab, $destOrphans)) {
                $info['destOrphan'] = true;
            } elseif (in_array($tab, $sourceOrphans)) {
                $info['sourceOrphan'] = true;
            } else {
                $destinationSql = $this->getTabSql($this->destination_structure, $tab, true);
                $sourceSql = $this->getTabSql($this->source_structure, $tab, true);
                $diffs = $this->compareSql($sourceSql, $destinationSql);

                if ($diffs === false) {
                    trigger_error('[WARNING] error parsing definition of table "' . $tab . '" - skipped');
                    continue;
                } elseif (!empty($diffs)) // not empty array
                {
                    $info['differs'] = $diffs;
                } else continue;//empty array
            }
            $result[$tab] = $info;
        }

        return $result;
    }
private function compare ( $ source , $ destination ) { $ this -> source_structure = $ source ; $ this -> destination_structure = $ destination ; $ result = [ ] ; $ destTabNames = $ this -> getTableList ( $ this -> destination_structure ) ; $ sourceTabNames = $ this -> getTableList ( $ this -> source_structure ) ; $ common = array_intersect ( $ destTabNames , $ sourceTabNames ) ; $ destOrphans = array_diff ( $ destTabNames , $ common ) ; $ sourceOrphans = array_diff ( $ sourceTabNames , $ common ) ; $ all = array_unique ( array_merge ( $ destTabNames , $ sourceTabNames ) ) ; sort ( $ all ) ; foreach ( $ all as $ tab ) { $ info = [ 'destOrphan' => false , 'sourceOrphan' => false , 'differs' => false ] ; if ( in_array ( $ tab , $ destOrphans ) ) { $ info [ 'destOrphan' ] = true ; } elseif ( in_array ( $ tab , $ sourceOrphans ) ) { $ info [ 'sourceOrphan' ] = true ; } else { $ destinationSql = $ this -> getTabSql ( $ this -> destination_structure , $ tab , true ) ; $ sourceSql = $ this -> getTabSql ( $ this -> source_structure , $ tab , true ) ; $ diffs = $ this -> compareSql ( $ sourceSql , $ destinationSql ) ; if ( $ diffs === false ) { trigger_error ( '[WARNING] error parsing definition of table "' . $ tab . '" - skipped' ) ; continue ; } elseif ( ! empty ( $ diffs ) ) // not empty array { $ info [ 'differs' ] = $ diffs ; } else continue ; //empty array } $ result [ $ tab ] = $ info ; } return $ result ; }
Makes comparison of the given database structures, support some options
@access private
@param string $source and $dest are strings - database tables structures
@param string $destination
@return array
- table (array)
- destOrphan (boolean)
- sourceOrphan (boolean)
- differs (array) OR (boolean) false if no diffs
- [0](array)
- source (string) structure definition line in the out-of-date table
- dest (string) structure definition line in the reference table
- [1](array) ...
Makes comparison of the given database structures support some options