PHP code example of asika / sql-splitter
1. Go to this page and download the library: Download asika/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/ */
asika / sql-splitter example snippets
use Asika\SqlSplitter\SqlSplitter;
$it = SqlSplitter::splitFromFile(__DIR__ . '/path/to/db.sql');
// Loop iterator
foreach ($it as $query) {
if (trim($query) !== '') {
$db->prepare($query)->execute();
}
}
// Or just convert to array
$queries = iterator_to_array($it);
// Available methods
SqlSplitter::splitSqlString('...');
SqlSplitter::splitFromFile('path/to/fil.sql');
SqlSplitter::splitFromPsr7Stream(new Stream('zip://file.zip#backup.sql'));
SqlSplitter::splitFromStream(fopen('s3://...', 'r'));