prepare(" SELECT oi.*, p.sku, p.category FROM order_items oi LEFT JOIN products p ON oi.product_id = p.id WHERE oi.order_id = ? ORDER BY oi.id ASC "); $stmt->execute([$orderId]); return $stmt->fetchAll(); } public static function create(array $data): int { $db = Database::getConnection(); $stmt = $db->prepare(" INSERT INTO order_items (order_id, product_id, product_name, quantity, unit_price, total_price) VALUES (:order_id, :product_id, :product_name, :quantity, :unit_price, :total_price) "); $stmt->execute([ ':order_id' => $data['order_id'], ':product_id' => $data['product_id'], ':product_name' => $data['product_name'], ':quantity' => $data['quantity'], ':unit_price' => $data['unit_price'], ':total_price' => $data['total_price'], ]); return (int)$db->lastInsertId(); } }