private function compareSql($sourceSql, $destinationSql)//$sourceSql, $destSql
    {
        $result = [];
        //split with comma delimiter, not line breaks
        $sourceParts = $this->splitTabSql($sourceSql);

        if ($sourceParts === false) // error parsing sql
        {
            trigger_error('[WARNING] error parsing source sql');
            return false;
        }

        $destinationParts = $this->splitTabSql($destinationSql);
        if ($destinationParts === false) {
            trigger_error('[WARNING] error parsing destination sql');
            return false;
        }

        $sourcePartsIndexed = [];
        $destinationPartsIndexed = [];

        foreach ($sourceParts as $line) {
            $lineInfo = $this->processLine($line);
            if (!$lineInfo) continue;
            $sourcePartsIndexed[$lineInfo['key']] = $lineInfo['line'];
        }

        foreach ($destinationParts as $line) {
            $lineInfo = $this->processLine($line);
            if (!$lineInfo) continue;
            $destinationPartsIndexed[$lineInfo['key']] = $lineInfo['line'];
        }

        $sourceKeys = array_keys($sourcePartsIndexed);
        $destinationKeys = array_keys($destinationPartsIndexed);
        $all = array_unique(array_merge($sourceKeys, $destinationKeys));
        sort($all); // fields first, then indexes - because fields are prefixed with '!'

        foreach ($all as $key) {
            $info = ['source' => '', 'dest' => ''];
            $inSource = in_array($key, $sourceKeys);
            $inDestination = in_array($key, $destinationKeys);
            $sourceOrphan = $inSource && !$inDestination;
            $destinationOrphan = $inDestination && !$inSource;
            $different = $inSource && $inDestination && strcasecmp($this->normalizeString($destinationPartsIndexed[$key]), $this->normalizeString($sourcePartsIndexed[$key]));

            if ($sourceOrphan) {
                $info['source'] = $sourcePartsIndexed[$key];
            } elseif ($destinationOrphan) {
                $info['dest'] = $destinationPartsIndexed[$key];
            } elseif ($different) {
                $info['source'] = $sourcePartsIndexed[$key];
                $info['dest'] = $destinationPartsIndexed[$key];
            } else continue;

            $result[] = $info;
        }

        return $result;
    }
private function compareSql($sourceSql, $destinationSql)//$sourceSql, $destSql
    {
        $result = [];
        //split with comma delimiter, not line breaks
        $sourceParts = $this->splitTabSql($sourceSql);

        if ($sourceParts === false) // error parsing sql
        {
            trigger_error('[WARNING] error parsing source sql');
            return false;
        }

        $destinationParts = $this->splitTabSql($destinationSql);
        if ($destinationParts === false) {
            trigger_error('[WARNING] error parsing destination sql');
            return false;
        }

        $sourcePartsIndexed = [];
        $destinationPartsIndexed = [];

        foreach ($sourceParts as $line) {
            $lineInfo = $this->processLine($line);
            if (!$lineInfo) continue;
            $sourcePartsIndexed[$lineInfo['key']] = $lineInfo['line'];
        }

        foreach ($destinationParts as $line) {
            $lineInfo = $this->processLine($line);
            if (!$lineInfo) continue;
            $destinationPartsIndexed[$lineInfo['key']] = $lineInfo['line'];
        }

        $sourceKeys = array_keys($sourcePartsIndexed);
        $destinationKeys = array_keys($destinationPartsIndexed);
        $all = array_unique(array_merge($sourceKeys, $destinationKeys));
        sort($all); // fields first, then indexes - because fields are prefixed with '!'

        foreach ($all as $key) {
            $info = ['source' => '', 'dest' => ''];
            $inSource = in_array($key, $sourceKeys);
            $inDestination = in_array($key, $destinationKeys);
            $sourceOrphan = $inSource && !$inDestination;
            $destinationOrphan = $inDestination && !$inSource;
            $different = $inSource && $inDestination && strcasecmp($this->normalizeString($destinationPartsIndexed[$key]), $this->normalizeString($sourcePartsIndexed[$key]));

            if ($sourceOrphan) {
                $info['source'] = $sourcePartsIndexed[$key];
            } elseif ($destinationOrphan) {
                $info['dest'] = $destinationPartsIndexed[$key];
            } elseif ($different) {
                $info['source'] = $sourcePartsIndexed[$key];
                $info['dest'] = $destinationPartsIndexed[$key];
            } else continue;

            $result[] = $info;
        }

        return $result;
    }
private function compareSql ( $ sourceSql , $ destinationSql ) //$sourceSql, $destSql { $ result = [ ] ; //split with comma delimiter, not line breaks $ sourceParts = $ this -> splitTabSql ( $ sourceSql ) ; if ( $ sourceParts === false ) // error parsing sql { trigger_error ( '[WARNING] error parsing source sql' ) ; return false ; } $ destinationParts = $ this -> splitTabSql ( $ destinationSql ) ; if ( $ destinationParts === false ) { trigger_error ( '[WARNING] error parsing destination sql' ) ; return false ; } $ sourcePartsIndexed = [ ] ; $ destinationPartsIndexed = [ ] ; foreach ( $ sourceParts as $ line ) { $ lineInfo = $ this -> processLine ( $ line ) ; if ( ! $ lineInfo ) continue ; $ sourcePartsIndexed [ $ lineInfo [ 'key' ] ] = $ lineInfo [ 'line' ] ; } foreach ( $ destinationParts as $ line ) { $ lineInfo = $ this -> processLine ( $ line ) ; if ( ! $ lineInfo ) continue ; $ destinationPartsIndexed [ $ lineInfo [ 'key' ] ] = $ lineInfo [ 'line' ] ; } $ sourceKeys = array_keys ( $ sourcePartsIndexed ) ; $ destinationKeys = array_keys ( $ destinationPartsIndexed ) ; $ all = array_unique ( array_merge ( $ sourceKeys , $ destinationKeys ) ) ; sort ( $ all ) ; // fields first, then indexes - because fields are prefixed with '!' foreach ( $ all as $ key ) { $ info = [ 'source' => '' , 'dest' => '' ] ; $ inSource = in_array ( $ key , $ sourceKeys ) ; $ inDestination = in_array ( $ key , $ destinationKeys ) ; $ sourceOrphan = $ inSource && ! $ inDestination ; $ destinationOrphan = $ inDestination && ! $ inSource ; $ different = $ inSource && $ inDestination && strcasecmp ( $ this -> normalizeString ( $ destinationPartsIndexed [ $ key ] ) , $ this -> normalizeString ( $ sourcePartsIndexed [ $ key ] ) ) ; if ( $ sourceOrphan ) { $ info [ 'source' ] = $ sourcePartsIndexed [ $ key ] ; } elseif ( $ destinationOrphan ) { $ info [ 'dest' ] = $ destinationPartsIndexed [ $ key ] ; } elseif ( $ different ) { $ info [ 'source' ] = $ sourcePartsIndexed [ $ key ] ; $ info [ 'dest' ] = $ destinationPartsIndexed [ $ key ] ; } else continue ; $ result [ ] = $ info ; } return $ result ; }
returns array of fields or keys definitions that differs in the given tables structure
@access private
@param string $sourceSql table structure
@param string $destinationSql right table structure
supports some $options
@return array
- [0]
- source (string) out-of-date table field definition
- dest (string) reference table field definition
- [1]...
returns array of fields or keys definitions that differs in the given tables structure