blob: 3bb4126b99bf525c1d4f2590aaf5e26341e4c3bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<?php
$srcSqlFile = "path/to/query.sql";
$dstDbFile = "path/to/sqlite.db";
$stmts = file_get_contents($srcSqlFile);
$stmts = explode(';', $stmts);
$db = new SQLite3($dstDbFile);
$db->enableExceptions(true);
foreach( $stmts AS $stmtStr ){
$stmtStr = trim($stmtStr);
if( !$stmtStr ) continue;
$st = $db->prepare($stmtStr .';');
$st->execute();
//$id = $db->lastInsertRowID();
//if( $id ){ echo "lastInsertRowID() -> $id\n"; }
$st->close();
}
$db->close();
|