private function getTabSql($struct, $tab, $removeDatabase = true)
    {
        $result = '';
        $database = '';
        $tableDef = '';

        /* create table should be single line in this case*/
        // 1 - part before database, 2-database name, 3 - part after database
        if (preg_match('/(CREATE(?:\s*TEMPORARY)?\s*TABLE\s*(?:IF NOT EXISTS\s*)?)(?:`?(\w+)`?\.)?(`?(' . $tab . ')`?(\W|$))/i', $struct, $m, PREG_OFFSET_CAPTURE)) {
            $tableDef = $m[0][0];
            $start = $m[0][1];
            $database = $m[2][0];
            $offset = $start + strlen($m[0][0]);
            $end = $this->getDelimiterPos($struct, $offset);
            if ($end === false) {
                $result = substr($struct, $start);
            } else {
                $result = substr($struct, $start, $end - $start);//already without ';'
            }
        }

        $result = trim($result);
        if ($database && $removeDatabase) {
            $result = str_replace($tableDef, $m[1][0] . $m[3][0], $result);
        }

        return $result;
    }
private function getTabSql($struct, $tab, $removeDatabase = true)
    {
        $result = '';
        $database = '';
        $tableDef = '';

        /* create table should be single line in this case*/
        // 1 - part before database, 2-database name, 3 - part after database
        if (preg_match('/(CREATE(?:\s*TEMPORARY)?\s*TABLE\s*(?:IF NOT EXISTS\s*)?)(?:`?(\w+)`?\.)?(`?(' . $tab . ')`?(\W|$))/i', $struct, $m, PREG_OFFSET_CAPTURE)) {
            $tableDef = $m[0][0];
            $start = $m[0][1];
            $database = $m[2][0];
            $offset = $start + strlen($m[0][0]);
            $end = $this->getDelimiterPos($struct, $offset);
            if ($end === false) {
                $result = substr($struct, $start);
            } else {
                $result = substr($struct, $start, $end - $start);//already without ';'
            }
        }

        $result = trim($result);
        if ($database && $removeDatabase) {
            $result = str_replace($tableDef, $m[1][0] . $m[3][0], $result);
        }

        return $result;
    }
private function getTabSql ( $ struct , $ tab , $ removeDatabase = true ) { $ result = '' ; $ database = '' ; $ tableDef = '' ; /* create table should be single line in this case*/ // 1 - part before database, 2-database name, 3 - part after database if ( preg_match ( '/(CREATE(?:\s*TEMPORARY)?\s*TABLE\s*(?:IF NOT EXISTS\s*)?)(?:`?(\w+)`?\.)?(`?(' . $ tab . ')`?(\W|$))/i' , $ struct , $ m , PREG_OFFSET_CAPTURE ) ) { $ tableDef = $ m [ 0 ] [ 0 ] ; $ start = $ m [ 0 ] [ 1 ] ; $ database = $ m [ 2 ] [ 0 ] ; $ offset = $ start + strlen ( $ m [ 0 ] [ 0 ] ) ; $ end = $ this -> getDelimiterPos ( $ struct , $ offset ) ; if ( $ end === false ) { $ result = substr ( $ struct , $ start ) ; } else { $ result = substr ( $ struct , $ start , $ end - $ start ) ; //already without ';' } } $ result = trim ( $ result ) ; if ( $ database && $ removeDatabase ) { $ result = str_replace ( $ tableDef , $ m [ 1 ] [ 0 ] . $ m [ 3 ] [ 0 ] , $ result ) ; } return $ result ; }
Retrieves table structure definition from the database structure dump
@access private
@param string $struct database structure listing
@param string $tab table name
@param bool $removeDatabase - either to remove database name in "CREATE TABLE database.tab"-like declarations
@return string table structure definition
Retrieves table structure definition from the database structure dump