Esempio n. 1
0
 static function findAllForRecipe($recipe_id, $dbh)
 {
     $stmt = $dbh->prepare("select * from " . RecipeStep::$nameTable . " where recipe_id = :recipe_id");
     $stmt->bindParam(":recipe_id", $recipe_id);
     $stmt->execute();
     $result = array();
     while ($row = $stmt->fetch()) {
         $rs = new RecipeStep();
         $rs->copyFromRow($row);
         $result[] = $rs;
     }
     return $result;
 }
Esempio n. 2
0
 public static function copy($params)
 {
     if (!isset($params["id"])) {
         throw new Exception("Missing id parameter");
     }
     // Connect to database
     $mysqli = FoodAppDatabase::connect();
     // Copy FOOD table record
     $foodFields = implode(",", array_slice(static::$fieldMap, 1));
     $queryString = "INSERT into food (" . $foodFields . ") ";
     $queryString .= "SELECT " . $foodFields . " FROM food ";
     $queryString .= "WHERE id='" . $params["id"] . "'";
     // Run query
     if (!$mysqli->query($queryString)) {
         throw new Exception($mysqli->error);
     }
     $newFoodId = $mysqli->insert_id;
     // Copy Reviews
     Review::copy($params["id"], $newFoodId);
     // Copy Components
     FoodComponent::copy($params["id"], $newFoodId);
     // Copy Recipe Steps
     RecipeStep::copy($params["id"], $newFoodId);
     // Copy Complements
     FoodComplement::copy($params["id"], $newFoodId);
     // Copy Alternates
     FoodAlternate::copy($params["id"], $newFoodId);
 }
Esempio n. 3
0
 function getRecipeSteps($dbh)
 {
     $this->recipe_steps = RecipeStep::findAllForRecipe($this->ID, $dbh);
 }
Esempio n. 4
0
 public function destroy()
 {
     return RecipeStep::destroy($this->params);
 }