protected function import()
    {
        $query = '';

        while (!feof($this->file)) {
            $line = fgets($this->file);
            $trim = trim($line);

            if ($trim === '' || strpos($trim, '--') === 0 || strpos($trim, '/*') === 0) {
                continue;
            }

            if (strpos($trim, 'DELIMITER ') === 0) {
                $this->delimiter = substr($trim, 10);
                continue;
            }

            $query .= $line;

            if (substr($trim, strlen($this->delimiter) * -1) === $this->delimiter) {
                $this->pdo->exec(substr(trim($query), 0, strlen($this->delimiter) * -1));
                $query = '';
            }
        }
    }
protected function import()
    {
        $query = '';

        while (!feof($this->file)) {
            $line = fgets($this->file);
            $trim = trim($line);

            if ($trim === '' || strpos($trim, '--') === 0 || strpos($trim, '/*') === 0) {
                continue;
            }

            if (strpos($trim, 'DELIMITER ') === 0) {
                $this->delimiter = substr($trim, 10);
                continue;
            }

            $query .= $line;

            if (substr($trim, strlen($this->delimiter) * -1) === $this->delimiter) {
                $this->pdo->exec(substr(trim($query), 0, strlen($this->delimiter) * -1));
                $query = '';
            }
        }
    }
protected function import ( ) { $ query = '' ; while ( ! feof ( $ this -> file ) ) { $ line = fgets ( $ this -> file ) ; $ trim = trim ( $ line ) ; if ( $ trim === '' || strpos ( $ trim , '--' ) === 0 || strpos ( $ trim , '/*' ) === 0 ) { continue ; } if ( strpos ( $ trim , 'DELIMITER ' ) === 0 ) { $ this -> delimiter = substr ( $ trim , 10 ) ; continue ; } $ query .= $ line ; if ( substr ( $ trim , strlen ( $ this -> delimiter ) * - 1 ) === $ this -> delimiter ) { $ this -> pdo -> exec ( substr ( trim ( $ query ) , 0 , strlen ( $ this -> delimiter ) * - 1 ) ) ; $ query = '' ; } } }
Processes the SQL file.

Reads a SQL file by line by line. Expects that
individual queries are separated by semicolons,
and that quoted values are properly escaped,
including newlines.

Queries themselves can not contain any comments.
All comments are stripped from the file.
Processes the SQL file .