-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackageJSON.php
More file actions
47 lines (31 loc) · 1.6 KB
/
packageJSON.php
File metadata and controls
47 lines (31 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require 'PackageData.php';
$package = new PackageData();
$recipeId = $_REQUEST["recipeId"];
try {
require 'dbConnect.php';
$sql = "SELECT recipe_id, recipe_title, recipe_image, recipe_serving_size, recipe_time, recipe_difficulty, recipe_ingredient_title,
recipe_ingredient_quantity, recipe_instruction_heading, recipe_instruction_body FROM recipe WHERE recipe_id = :recipeId";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':recipeId', $recipeId);
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$row = $stmt->fetch();
$package->setRecipeTitle($row['recipe_title']);
$package->setRecipeImage($row['recipe_image']);
$package->setRecipeServingSize($row['recipe_serving_size']);
$package->setRecipeTime($row['recipe_time']);
$package->setRecipeDifficulty($row['recipe_difficulty']);
$package->setIngredientTitles(json_decode($row['recipe_ingredient_title']));
$package->setIngredientQuantities(json_decode($row['recipe_ingredient_quantity']));
$package->setInstructionHeadings(json_decode($row['recipe_instruction_heading']));
$package->setInstructionBodies(json_decode($row['recipe_instruction_body']));
}
catch (PDOException $e) {
$errMsg = "There has been a problem. The system administrator has been contacted. Please try again later.";
error_log($e->getMessage());
error_log($e->getLine());
error_log(var_dump(debug_backtrace()));
echo $errMsg;
}
echo json_encode($package);