Advertisement
darryljf

recipe.class.php - latest

Apr 5th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2.  
  3. class Recipe{
  4.   protected $Conn;
  5.  
  6.   public function __construct($Conn){
  7.     $this->Conn = $Conn;
  8.   }
  9.  
  10.   public function addRecipe($data){
  11.  
  12.     $query = "INSERT INTO recipes(cat_id,user_id,recipe_name,recipe_image,recipe_instructions) VALUES (:cat_id,:user_id,:recipe_name,:recipe_image,:recipe_instructions)";
  13.     $stmt = $this->Conn->prepare($query);
  14.     $data['user_id'] = $_SESSION['user_data']['user_id'];
  15.     return $stmt->execute($data);
  16.   }
  17.  
  18.   public function getRecipesForCat($cat_id) {
  19.  
  20.     $query = "SELECT * FROM recipes WHERE cat_id = :cat_id";
  21.     $stmt = $this->Conn->prepare($query);
  22.     $stmt->execute();
  23.     return $stmt->fetchAll(PDO::FETCH_ASSOC);
  24.   }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement