Files
PhotoGal/web/scripts/init_db.php
2024-08-27 19:03:24 -05:00

29 lines
643 B
PHP

<?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.";
}