| 1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- require_once __DIR__ . '/config/database.php';
- try {
- $database = new Database();
- $conn = $database->getConnection();
-
- if (!$conn) {
- throw new Exception('Database connection failed');
- }
-
- // Read and execute the schema file
- $schemaFile = __DIR__ . '/database/accounting_category_groups_schema.sql';
- $schema = file_get_contents($schemaFile);
-
- // Split by semicolons and execute each statement
- $statements = array_filter(array_map('trim', explode(';', $schema)));
-
- foreach ($statements as $statement) {
- if (!empty($statement)) {
- try {
- $conn->exec($statement);
- echo "Executed: " . $statement . "\n";
- } catch (Exception $e) {
- echo "Error: " . $e->getMessage() . "\n";
- }
- }
- }
-
- echo "Category groups table created successfully!\n";
-
- } catch (Exception $e) {
- echo "Error: " . $e->getMessage() . "\n";
- }
- ?>
|