27 lines
866 B
PHP
27 lines
866 B
PHP
<?php
|
|
|
|
require __DIR__.'/../vendor/autoload.php';
|
|
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
$bible = json_decode(file_get_contents(dirname(__DIR__).'/var/esv-bible.json'));
|
|
$db = new PDO('sqlite:'.dirname(__DIR__).'/var/data.db');
|
|
|
|
foreach ($bible as $book => $data) {
|
|
$stmt = $db->prepare('INSERT INTO bible (id, book, chapter, verse, content, book_index) VALUES (:id, :book, :chapter, :verse, :content, :book_index)');
|
|
|
|
foreach ($data->text as $chapter => $verses) {
|
|
foreach ($verses as $verse => $text) {
|
|
print "{$book} {$chapter}:{$verse}".PHP_EOL;
|
|
$stmt->execute([
|
|
'id' => Uuid::v4(),
|
|
'book' => $book,
|
|
'chapter' => $chapter,
|
|
'verse' => ($verse + 1),
|
|
'content' => $text,
|
|
'book_index' => $data->index
|
|
]);
|
|
}
|
|
}
|
|
}
|