Initial commit
This commit is contained in:
28
web/scripts/init_db.php
Normal file
28
web/scripts/init_db.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
// .php
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Hpz\Photogal\Database;
|
||||
use Hpz\Photogal\Image;
|
||||
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
|
||||
$dotenv->load();
|
||||
if (!isset($_ENV['DB_FILE_PATH'])) {
|
||||
die('DB_FILE_PATH is not set in the .env file');
|
||||
}
|
||||
|
||||
// Specify the path to the SQLite database file
|
||||
$dbFilePath = $_ENV['DB_FILE_PATH'];
|
||||
|
||||
// Create a new Database connection
|
||||
$database = new Database($dbFilePath);
|
||||
|
||||
// Create the Image table
|
||||
$image = new Image($database);
|
||||
if ($image->createTable()) {
|
||||
echo "Database and table initialized successfully.";
|
||||
} else {
|
||||
echo "Failed to initialize database and table.";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user