private function processLine($line)
    {
        $options = $this->config;
        $result = ['key' => '', 'line' => ''];
        $line = rtrim(trim($line), ',');

        if (preg_match('/^(CREATE\s+TABLE)|(\) ENGINE=)/i', $line)) // first or last table definition line
        {
            return false;
        }

        // if (preg_match('/^(PRIMARY KEY)|(((UNIQUE )|(FULLTEXT ))?KEY `?\w+`?)/i', $line, $m))//key definition

        if (preg_match('/^(PRIMARY\s+KEY)|(((UNIQUE\s+)|(FULLTEXT\s+))?KEY\s+`?\w+`?)/i', $line, $m))//key definition
        {
            $key = $m[0];
        } elseif (preg_match('/^`?\w+`?/i', $line, $m))//field definition
        {
            $key = '!' . $m[0];//to make sure fields will be synchronised before the keys
        } else {
            return false;//line has no valuable info (empty or comment)
        }

        // $key = str_replace('`', '', $key);
        if (!empty($options['varcharDefaultIgnore'])) {
            $line = preg_replace("/(var)?char\(([0-9]+)\)\s+NOT\s+NULL\s+default\s+''/i", '$1char($2) NOT NULL', $line);
        }
        if (!empty($options['intDefaultIgnore'])) {
            $line = preg_replace("/((?:big)|(?:tiny))?int\(([0-9]+)\)\s+NOT\s+NULL\s+default\s+'0'/i", '$1int($2) NOT NULL', $line);
        }
        if (!empty($options['ignoreIncrement'])) {
            $line = preg_replace("/ AUTO_INCREMENT=[0-9]+/i", '', $line);
        }

        $result['key'] = $this->normalizeString($key);
        $result['line'] = $line;

        return $result;
    }
private function processLine($line)
    {
        $options = $this->config;
        $result = ['key' => '', 'line' => ''];
        $line = rtrim(trim($line), ',');

        if (preg_match('/^(CREATE\s+TABLE)|(\) ENGINE=)/i', $line)) // first or last table definition line
        {
            return false;
        }

        // if (preg_match('/^(PRIMARY KEY)|(((UNIQUE )|(FULLTEXT ))?KEY `?\w+`?)/i', $line, $m))//key definition

        if (preg_match('/^(PRIMARY\s+KEY)|(((UNIQUE\s+)|(FULLTEXT\s+))?KEY\s+`?\w+`?)/i', $line, $m))//key definition
        {
            $key = $m[0];
        } elseif (preg_match('/^`?\w+`?/i', $line, $m))//field definition
        {
            $key = '!' . $m[0];//to make sure fields will be synchronised before the keys
        } else {
            return false;//line has no valuable info (empty or comment)
        }

        // $key = str_replace('`', '', $key);
        if (!empty($options['varcharDefaultIgnore'])) {
            $line = preg_replace("/(var)?char\(([0-9]+)\)\s+NOT\s+NULL\s+default\s+''/i", '$1char($2) NOT NULL', $line);
        }
        if (!empty($options['intDefaultIgnore'])) {
            $line = preg_replace("/((?:big)|(?:tiny))?int\(([0-9]+)\)\s+NOT\s+NULL\s+default\s+'0'/i", '$1int($2) NOT NULL', $line);
        }
        if (!empty($options['ignoreIncrement'])) {
            $line = preg_replace("/ AUTO_INCREMENT=[0-9]+/i", '', $line);
        }

        $result['key'] = $this->normalizeString($key);
        $result['line'] = $line;

        return $result;
    }
private function processLine ( $ line ) { $ options = $ this -> config ; $ result = [ 'key' => '' , 'line' => '' ] ; $ line = rtrim ( trim ( $ line ) , ',' ) ; if ( preg_match ( '/^(CREATE\s+TABLE)|(\) ENGINE=)/i' , $ line ) ) // first or last table definition line { return false ; } // if (preg_match('/^(PRIMARY KEY)|(((UNIQUE )|(FULLTEXT ))?KEY `?\w+`?)/i', $line, $m))//key definition if ( preg_match ( '/^(PRIMARY\s+KEY)|(((UNIQUE\s+)|(FULLTEXT\s+))?KEY\s+`?\w+`?)/i' , $ line , $ m ) ) //key definition { $ key = $ m [ 0 ] ; } elseif ( preg_match ( '/^`?\w+`?/i' , $ line , $ m ) ) //field definition { $ key = '!' . $ m [ 0 ] ; //to make sure fields will be synchronised before the keys } else { return false ; //line has no valuable info (empty or comment) } // $key = str_replace('`', '', $key); if ( ! empty ( $ options [ 'varcharDefaultIgnore' ] ) ) { $ line = preg_replace ( "/(var)?char\(([0-9]+)\)\s+NOT\s+NULL\s+default\s+''/i" , '$1char($2) NOT NULL' , $ line ) ; } if ( ! empty ( $ options [ 'intDefaultIgnore' ] ) ) { $ line = preg_replace ( "/((?:big)|(?:tiny))?int\(([0-9]+)\)\s+NOT\s+NULL\s+default\s+'0'/i" , '$1int($2) NOT NULL' , $ line ) ; } if ( ! empty ( $ options [ 'ignoreIncrement' ] ) ) { $ line = preg_replace ( "/ AUTO_INCREMENT=[0-9]+/i" , '' , $ line ) ; } $ result [ 'key' ] = $ this -> normalizeString ( $ key ) ; $ result [ 'line' ] = $ line ; return $ result ; }
Transforms table structure definition line into key=>value pair where the key is a string that uniquely
defines field or key described
@access private
@param string $line field definition string
@return array array with single key=>value pair as described in the description
implements some options
Transforms table structure definition line into key = > value pair where the key is a string that uniquely defines field or key described