private function splitTabSql($sql)
    {
        $result = [];
        //find opening bracket, get the prefix along with it
        $openBracketPos = $this->getDelimiterPos($sql, 0, '(');

        if ($openBracketPos === false) {
            trigger_error('[WARNING] can not find opening bracket in table definition');
            return false;
        }

        $prefix = substr($sql, 0, $openBracketPos + 1); // prefix can not be empty, so do not check it, just trim
        $result[] = trim($prefix);
        $body = substr($sql, strlen($prefix)); // fields, indexes and part after closing bracket

        //split by commas, get part by part
        while (($commaPos = $this->getDelimiterPos($body, 0, ',', true)) !== false) {
            $part = trim(substr($body, 0, $commaPos + 1));//read another part and shorten $body
            if ($part) {
                $result[] = $part;
            }
            $body = substr($body, $commaPos + 1);
        }

        // here we have last field (or index) definition + part after closing bracket (ENGINE, ect)
        $closeBracketPos = $this->getDelimiterRightPosition($body, 0, ')');
        if ($closeBracketPos === false) {
            trigger_error('[WARNING] can not find closing bracket in table definition');
            return false;
        }

        // get last field / index definition before closing bracket
        $part = substr($body, 0, $closeBracketPos);
        $result[] = trim($part);

        // get the suffix part along with the closing bracket
        $suffix = substr($body, $closeBracketPos);
        $suffix = trim($suffix);
        if ($suffix) {
            $result[] = $suffix;
        }

        return $result;
    }
private function splitTabSql($sql)
    {
        $result = [];
        //find opening bracket, get the prefix along with it
        $openBracketPos = $this->getDelimiterPos($sql, 0, '(');

        if ($openBracketPos === false) {
            trigger_error('[WARNING] can not find opening bracket in table definition');
            return false;
        }

        $prefix = substr($sql, 0, $openBracketPos + 1); // prefix can not be empty, so do not check it, just trim
        $result[] = trim($prefix);
        $body = substr($sql, strlen($prefix)); // fields, indexes and part after closing bracket

        //split by commas, get part by part
        while (($commaPos = $this->getDelimiterPos($body, 0, ',', true)) !== false) {
            $part = trim(substr($body, 0, $commaPos + 1));//read another part and shorten $body
            if ($part) {
                $result[] = $part;
            }
            $body = substr($body, $commaPos + 1);
        }

        // here we have last field (or index) definition + part after closing bracket (ENGINE, ect)
        $closeBracketPos = $this->getDelimiterRightPosition($body, 0, ')');
        if ($closeBracketPos === false) {
            trigger_error('[WARNING] can not find closing bracket in table definition');
            return false;
        }

        // get last field / index definition before closing bracket
        $part = substr($body, 0, $closeBracketPos);
        $result[] = trim($part);

        // get the suffix part along with the closing bracket
        $suffix = substr($body, $closeBracketPos);
        $suffix = trim($suffix);
        if ($suffix) {
            $result[] = $suffix;
        }

        return $result;
    }
private function splitTabSql ( $ sql ) { $ result = [ ] ; //find opening bracket, get the prefix along with it $ openBracketPos = $ this -> getDelimiterPos ( $ sql , 0 , '(' ) ; if ( $ openBracketPos === false ) { trigger_error ( '[WARNING] can not find opening bracket in table definition' ) ; return false ; } $ prefix = substr ( $ sql , 0 , $ openBracketPos + 1 ) ; // prefix can not be empty, so do not check it, just trim $ result [ ] = trim ( $ prefix ) ; $ body = substr ( $ sql , strlen ( $ prefix ) ) ; // fields, indexes and part after closing bracket //split by commas, get part by part while ( ( $ commaPos = $ this -> getDelimiterPos ( $ body , 0 , ',' , true ) ) !== false ) { $ part = trim ( substr ( $ body , 0 , $ commaPos + 1 ) ) ; //read another part and shorten $body if ( $ part ) { $ result [ ] = $ part ; } $ body = substr ( $ body , $ commaPos + 1 ) ; } // here we have last field (or index) definition + part after closing bracket (ENGINE, ect) $ closeBracketPos = $ this -> getDelimiterRightPosition ( $ body , 0 , ')' ) ; if ( $ closeBracketPos === false ) { trigger_error ( '[WARNING] can not find closing bracket in table definition' ) ; return false ; } // get last field / index definition before closing bracket $ part = substr ( $ body , 0 , $ closeBracketPos ) ; $ result [ ] = trim ( $ part ) ; // get the suffix part along with the closing bracket $ suffix = substr ( $ body , $ closeBracketPos ) ; $ suffix = trim ( $ suffix ) ; if ( $ suffix ) { $ result [ ] = $ suffix ; } return $ result ; }
Splits table sql into indexed array
@param string $sql
@return array|bool
Splits table sql into indexed array