Auto stash before merge of "main" and "origin/main"

This commit is contained in:
2024-02-09 21:11:19 -06:00
parent f5d267ea98
commit d21d91b80e
17 changed files with 844 additions and 7 deletions

41
db_setup.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Hpz937\BillReminder\Database\SQLiteAdapter;
// Initialize the SQLite database adapter
$dbAdapter = new SQLiteAdapter();
$db = $dbAdapter->connect();
// SQL for creating the 'users' table
$createUsersTable = <<<SQL
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE
);
SQL;
// SQL for creating the 'bills' table
$createBillsTable = <<<SQL
CREATE TABLE IF NOT EXISTS bills (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
due_date DATE NOT NULL,
amount DECIMAL(10, 2) NOT NULL,
description TEXT,
is_paid INTEGER DEFAULT 0,
FOREIGN KEY (user_id) REFERENCES users(id)
);
SQL;
// Execute the SQL queries to create the tables
try {
$db->exec($createUsersTable);
$db->exec($createBillsTable);
echo "Database setup completed successfully.\n";
} catch (Exception $e) {
echo "Error setting up the database: " . $e->getMessage() . "\n";
}