diff options
author | Andreas Fankhauser hiddenalpha.ch | 2023-11-01 22:56:59 +0100 |
---|---|---|
committer | Andreas Fankhauser hiddenalpha.ch | 2023-11-01 22:56:59 +0100 |
commit | 3f03f7ba9e443886a141068c04b448b134ff6886 (patch) | |
tree | 988c21e187aa483210563d1b53921d64797d5886 | |
parent | 14d5192d803fa5850ef1631f51d7d4b3ff497622 (diff) | |
download | UnspecifiedGarbage-3f03f7ba9e443886a141068c04b448b134ff6886.zip UnspecifiedGarbage-3f03f7ba9e443886a141068c04b448b134ff6886.tar.gz |
Tried to run SQLite scripts from file via php. Bad luck, seems as php cannot do it.
-rw-r--r-- | src/main/php/sqlite-exec.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/php/sqlite-exec.php b/src/main/php/sqlite-exec.php new file mode 100644 index 0000000..8df2fe0 --- /dev/null +++ b/src/main/php/sqlite-exec.php @@ -0,0 +1,30 @@ +<?php + +throw new Exception("Sorry, cannot just execute from file :("); + + +function run( $app ){ + $lotsOfSql = file_get_contents($app->srcPath); + if( !$lotsOfSql ) throw new Exception("fopen(\"{$app->srcPath}\")"); + $app->db = new SQLite3($app->dstPath); + if( !$app->db ) throw new Exception("SQLite3(\"{$app->dstPath}\")"); + $db = $app->db; + $db->enableExceptions(true); + $st = $db->prepare($lotsOfSql); + $st->execute(); + $st->close(); +} + + +function main(){ + $app = (object)array( + "srcPath" => NULL/*TODO set me*/, + "dstPath" => NULL/*TODO set me*/, + "srcFile" => NULL, + "db" => NULL, + ); + run($app); +} + + +main(); |