exec(" CREATE TABLE IF NOT EXISTS `orders` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `customer_name` VARCHAR(255) NOT NULL, `customer_email` VARCHAR(255) NOT NULL, `total_amount` DECIMAL(10, 2) NOT NULL, `status` VARCHAR(50) NOT NULL DEFAULT 'Pending', `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) "); // Create order_items table $pdo->exec(" CREATE TABLE IF NOT EXISTS `order_items` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `order_id` INT NOT NULL, `product_id` INT NOT NULL, `quantity` INT NOT NULL, `price` DECIMAL(10, 2) NOT NULL, FOREIGN KEY (`order_id`) REFERENCES `orders`(`id`) ON DELETE CASCADE, FOREIGN KEY (`product_id`) REFERENCES `products`(`id`) ON DELETE RESTRICT ) "); echo "Tables 'orders' and 'order_items' created successfully." . PHP_EOL; } catch (PDOException $e) { die("DB ERROR: " . $e->getMessage()); }