30 lines
658 B
PHP
30 lines
658 B
PHP
<?php
|
|
require_once __DIR__ . '/../config.php';
|
|
|
|
function get_comments_by_recipe($recipe_id) {
|
|
$conn = db_connect();
|
|
$sql = "SELECT * FROM Comments WHERE RecipeId = ?";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bind_param("i", $recipe_id);
|
|
$stmt->execute();
|
|
|
|
$result = $stmt->get_result();
|
|
$comments = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$comments[] = $row;
|
|
}
|
|
|
|
$stmt->close();
|
|
$conn->close();
|
|
return json_encode($comments);
|
|
}
|
|
|
|
function create_comment($recipe_id) {
|
|
// Gleiche Logik wie im vorherigen Beispiel
|
|
}
|
|
|
|
function delete_comment($id) {
|
|
// Gleiche Logik wie im vorherigen Beispiel
|
|
}
|
|
?>
|