private function _loadPatchFile($file, $location, $minimumLevel, $maximumLevel)
    {
        if ($sql = file_get_contents($file)) {
            if ($this->encoding && ($this->encoding !== mb_internal_encoding())) {
                $sql = mb_convert_encoding($sql, mb_internal_encoding(), $this->encoding);
            }

            $levels = preg_split('/--\s*(GEMS\s+)?VERSION:?\s*/', $sql);

            // SQL before first -- VERSION: is ignored.
            array_shift($levels);

            foreach ($levels as $level) {
                list($levelnrtext, $leveltext) = explode("\n", $level, 2);

                // no loading of unused patches
                $levelnr = intval($levelnrtext);
                if ($levelnr && ($levelnr >= $minimumLevel) && ($levelnr <= $maximumLevel)) {

                    $patches = preg_split('/--\s*PATCH:?\s*/', $leveltext);

                    // SQL before first -- PATCH: is ignored.
                    array_shift($patches);

                    foreach ($patches as $patch) {
                        // First line now contains patch name
                        list($name, $statements) = explode("\n", $patch, 2);

                        $name = substr(trim($name), 0, 30);

                        // \MUtil_Echo::r($statements, $name);
                        foreach (\MUtil_Parser_Sql_WordsParser::splitStatements($statements, false) as $i => $statement) {
                            $this->_loaded_patches[] = array(
                                    'gpa_level'    => $levelnr,
                                    'gpa_location' => $location,
                                    'gpa_name'     => $name,
                                    'gpa_order'    => $i,
                                    'gpa_sql'      => $statement,
                                );
                        }
                    }

                }
            }
        }
    }
private function _loadPatchFile($file, $location, $minimumLevel, $maximumLevel)
    {
        if ($sql = file_get_contents($file)) {
            if ($this->encoding && ($this->encoding !== mb_internal_encoding())) {
                $sql = mb_convert_encoding($sql, mb_internal_encoding(), $this->encoding);
            }

            $levels = preg_split('/--\s*(GEMS\s+)?VERSION:?\s*/', $sql);

            // SQL before first -- VERSION: is ignored.
            array_shift($levels);

            foreach ($levels as $level) {
                list($levelnrtext, $leveltext) = explode("\n", $level, 2);

                // no loading of unused patches
                $levelnr = intval($levelnrtext);
                if ($levelnr && ($levelnr >= $minimumLevel) && ($levelnr <= $maximumLevel)) {

                    $patches = preg_split('/--\s*PATCH:?\s*/', $leveltext);

                    // SQL before first -- PATCH: is ignored.
                    array_shift($patches);

                    foreach ($patches as $patch) {
                        // First line now contains patch name
                        list($name, $statements) = explode("\n", $patch, 2);

                        $name = substr(trim($name), 0, 30);

                        // \MUtil_Echo::r($statements, $name);
                        foreach (\MUtil_Parser_Sql_WordsParser::splitStatements($statements, false) as $i => $statement) {
                            $this->_loaded_patches[] = array(
                                    'gpa_level'    => $levelnr,
                                    'gpa_location' => $location,
                                    'gpa_name'     => $name,
                                    'gpa_order'    => $i,
                                    'gpa_sql'      => $statement,
                                );
                        }
                    }

                }
            }
        }
    }
private function _loadPatchFile ( $ file , $ location , $ minimumLevel , $ maximumLevel ) { if ( $ sql = file_get_contents ( $ file ) ) { if ( $ this -> encoding && ( $ this -> encoding !== mb_internal_encoding ( ) ) ) { $ sql = mb_convert_encoding ( $ sql , mb_internal_encoding ( ) , $ this -> encoding ) ; } $ levels = preg_split ( '/--\s*(GEMS\s+)?VERSION:?\s*/' , $ sql ) ; // SQL before first -- VERSION: is ignored.
 array_shift ( $ levels ) ; foreach ( $ levels as $ level ) { list ( $ levelnrtext , $ leveltext ) = explode ( "\n" , $ level , 2 ) ; // no loading of unused patches
 $ levelnr = intval ( $ levelnrtext ) ; if ( $ levelnr && ( $ levelnr >= $ minimumLevel ) && ( $ levelnr <= $ maximumLevel ) ) { $ patches = preg_split ( '/--\s*PATCH:?\s*/' , $ leveltext ) ; // SQL before first -- PATCH: is ignored.
 array_shift ( $ patches ) ; foreach ( $ patches as $ patch ) { // First line now contains patch name
 list ( $ name , $ statements ) = explode ( "\n" , $ patch , 2 ) ; $ name = substr ( trim ( $ name ) , 0 , 30 ) ; // \MUtil_Echo::r($statements, $name);
 foreach ( \ MUtil_Parser_Sql_WordsParser :: splitStatements ( $ statements , false ) as $ i => $ statement ) { $ this -> _loaded_patches [ ] = array ( 'gpa_level' => $ levelnr , 'gpa_location' => $ location , 'gpa_name' => $ name , 'gpa_order' => $ i , 'gpa_sql' => $ statement , ) ; } } } } } }
Load all patches from a single patch file

@param string $file Full filename
@param string $location Location description
@param int $minimumLevel
@param int $maximumLevel
Load all patches from a single patch file