1. Go to this page and download the library: Download szonov/sql-splitter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
szonov / sql-splitter example snippets
use SZonov\Text\Source\Text as Input;
use SZonov\SQL\Splitter\Postgresql as Parser;
use SZonov\Text\Parser\ParserIterator as Queries;
$sql = "CREATE TABLE a (id SERIAL PRIMARY KEY, val TEXT);"
. "INSERT INTO a (val) VALUES ('myval');";
$input = new Input($sql);
$parser = new Parser($input);
$queries = new Queries($parser);
foreach ($queries as $query) {
// make something useful with single query
echo "[" . $query . "]\n";
}
use SZonov\SQL\Splitter\Postgresql as Parser;
use SZonov\Text\Parser\ParserIterator as Queries;
$queries = new Queries(Parser::fromFile('test.sql'));
foreach ($queries as $query) {
// make something useful with single query
echo "[" . $query . "]\n";
}
use SZonov\SQL\Splitter\Parser;
//$queries = Parser::fromFileUsingDriver('test.sql', 'mysql')->queries();
$queries = Parser::fromFileUsingDriver('test.sql', 'pgsql')->queries();
foreach ($queries as $query) {
// make something useful with single query
echo "[" . $query . "]\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.