public static function importSql(\PDO $databaseHandle, string $pdoDriver, string $pathAndFilename)
    {
        $sql = file($pathAndFilename, FILE_IGNORE_NEW_LINES & FILE_SKIP_EMPTY_LINES);
        // Remove MySQL style key length delimiters (yuck!) if we are not setting up a MySQL db
        if ($pdoDriver !== 'mysql') {
            $sql = preg_replace('/"\([0-9]+\)/', '"', $sql);
        }

        $statement = '';
        foreach ($sql as $line) {
            $statement .= ' ' . trim($line);
            if (substr($statement, -1) === ';') {
                $databaseHandle->exec($statement);
                $statement = '';
            }
        }
    }
public static function importSql(\PDO $databaseHandle, string $pdoDriver, string $pathAndFilename)
    {
        $sql = file($pathAndFilename, FILE_IGNORE_NEW_LINES & FILE_SKIP_EMPTY_LINES);
        // Remove MySQL style key length delimiters (yuck!) if we are not setting up a MySQL db
        if ($pdoDriver !== 'mysql') {
            $sql = preg_replace('/"\([0-9]+\)/', '"', $sql);
        }

        $statement = '';
        foreach ($sql as $line) {
            $statement .= ' ' . trim($line);
            if (substr($statement, -1) === ';') {
                $databaseHandle->exec($statement);
                $statement = '';
            }
        }
    }
public static function importSql ( \ PDO $ databaseHandle , string $ pdoDriver , string $ pathAndFilename ) { $ sql = file ( $ pathAndFilename , FILE_IGNORE_NEW_LINES & FILE_SKIP_EMPTY_LINES ) ; // Remove MySQL style key length delimiters (yuck!) if we are not setting up a MySQL db if ( $ pdoDriver !== 'mysql' ) { $ sql = preg_replace ( '/"\([0-9]+\)/' , '"' , $ sql ) ; } $ statement = '' ; foreach ( $ sql as $ line ) { $ statement .= ' ' . trim ( $ line ) ; if ( substr ( $ statement , - 1 ) === ';' ) { $ databaseHandle -> exec ( $ statement ) ; $ statement = '' ; } } }
Pumps the SQL into the database. Use for DDL only.

Important: key definitions with length specifiers (needed for MySQL) must
be given as "field"(xyz) - no space between double quote and parenthesis -
so they can be removed automatically.

@param \PDO $databaseHandle
@param string $pdoDriver
@param string $pathAndFilename
@return void
Pumps the SQL into the database . Use for DDL only .