public function load($sql)
    {
        $query = '';
        $delimiter = ';';
        $delimiterLength = 1;

        $dollarsOpen = false;
        foreach ($sql as $sqlLine) {
            if (preg_match('/DELIMITER ([\;\$\|\\\\]+)/i', $sqlLine, $match)) {
                $delimiter = $match[1];
                $delimiterLength = strlen($delimiter);
                continue;
            }

            $parsed = trim($query) == '' && $this->sqlLine($sqlLine);
            if ($parsed) {
                continue;
            }

            // Ignore $$ inside SQL standard string syntax such as in INSERT statements.
            if (!preg_match('/\'.*\$\$.*\'/', $sqlLine)) {
                $pos = strpos($sqlLine, '$$');
                if (($pos !== false) && ($pos >= 0)) {
                    $dollarsOpen = !$dollarsOpen;
                }
            }

            if (preg_match('/SET search_path = .*/i', $sqlLine, $match)) {
                $this->searchPath = $match[0];
            }

            $query .= "\n" . rtrim($sqlLine);

            if (!$dollarsOpen && substr($query, -1 * $delimiterLength, $delimiterLength) == $delimiter) {
                $this->sqlQuery(substr($query, 0, -1 * $delimiterLength));
                $query = '';
            }
        }

        if ($query !== '') {
            $this->sqlQuery($query);
        }
    }
public function load($sql)
    {
        $query = '';
        $delimiter = ';';
        $delimiterLength = 1;

        $dollarsOpen = false;
        foreach ($sql as $sqlLine) {
            if (preg_match('/DELIMITER ([\;\$\|\\\\]+)/i', $sqlLine, $match)) {
                $delimiter = $match[1];
                $delimiterLength = strlen($delimiter);
                continue;
            }

            $parsed = trim($query) == '' && $this->sqlLine($sqlLine);
            if ($parsed) {
                continue;
            }

            // Ignore $$ inside SQL standard string syntax such as in INSERT statements.
            if (!preg_match('/\'.*\$\$.*\'/', $sqlLine)) {
                $pos = strpos($sqlLine, '$$');
                if (($pos !== false) && ($pos >= 0)) {
                    $dollarsOpen = !$dollarsOpen;
                }
            }

            if (preg_match('/SET search_path = .*/i', $sqlLine, $match)) {
                $this->searchPath = $match[0];
            }

            $query .= "\n" . rtrim($sqlLine);

            if (!$dollarsOpen && substr($query, -1 * $delimiterLength, $delimiterLength) == $delimiter) {
                $this->sqlQuery(substr($query, 0, -1 * $delimiterLength));
                $query = '';
            }
        }

        if ($query !== '') {
            $this->sqlQuery($query);
        }
    }
public function load ( $ sql ) { $ query = '' ; $ delimiter = ';' ; $ delimiterLength = 1 ; $ dollarsOpen = false ; foreach ( $ sql as $ sqlLine ) { if ( preg_match ( '/DELIMITER ([\;\$\|\\\\]+)/i' , $ sqlLine , $ match ) ) { $ delimiter = $ match [ 1 ] ; $ delimiterLength = strlen ( $ delimiter ) ; continue ; } $ parsed = trim ( $ query ) == '' && $ this -> sqlLine ( $ sqlLine ) ; if ( $ parsed ) { continue ; } // Ignore $$ inside SQL standard string syntax such as in INSERT statements. if ( ! preg_match ( '/\'.*\$\$.*\'/' , $ sqlLine ) ) { $ pos = strpos ( $ sqlLine , '$$' ) ; if ( ( $ pos !== false ) && ( $ pos >= 0 ) ) { $ dollarsOpen = ! $ dollarsOpen ; } } if ( preg_match ( '/SET search_path = .*/i' , $ sqlLine , $ match ) ) { $ this -> searchPath = $ match [ 0 ] ; } $ query .= "\n" . rtrim ( $ sqlLine ) ; if ( ! $ dollarsOpen && substr ( $ query , - 1 * $ delimiterLength , $ delimiterLength ) == $ delimiter ) { $ this -> sqlQuery ( substr ( $ query , 0 , - 1 * $ delimiterLength ) ) ; $ query = '' ; } } if ( $ query !== '' ) { $ this -> sqlQuery ( $ query ) ; } }
Loads a SQL file.

@param string $sql sql file
Loads a SQL file .