Example #1
0
<?php

require_once "models/DB.php";
require_once "models/Recipe.php";
require_once "models/Ingredient.php";
require_once "models/units_of_measure.php";
require_once "models/RecipeIngredientUnit.php";
require_once "models/IngredientLayout.php";
require_once "models/Step.php";
// Route 1: user comes here to see a specific recipe
//   get the id of the recipe they want from the query string,
//   inflate a recipe model, and show them the detail view
//make new recipy and find it based on the ID of the selected anchor
$details = new Recipe();
$details->find($viewID, $dbh);
$steps = Step::findAllSteps($dbh, $details->id);
$riu = RecipeIngredientUnit::findAllForRecipe($details->id, $dbh);
$ingredients = array();
foreach ($riu as $i) {
    //$p = new IngredientLayout();
    //$p->amount = $i->amount;
    //$p->ingredient = Ingredient::findName($i->ingredient_id,$dbh);
    //$p->unit= units_of_measure::findName($i->unit_id,$dbh);
    //$ingredients[] = $p;
}
print_r($ingredients);
require_once "views/view_recipe.php";
Example #2
0
    $editRecipe = 0;
    require_once "views/edit_recipe.php";
    die;
} else {
    if (isset($_GET['edit'])) {
        require_once "models/DB.php";
        require_once "models/Recipe.php";
        require_once "models/Ingredient.php";
        require_once "models/units_of_measure.php";
        require_once "models/Step.php";
        //pull ingredients and units of measure alphabetically from database
        $ing = Ingredient::findAll($dbh);
        $units = units_of_measure::findAll($dbh);
        $newEntry = new Recipe();
        $newEntry->find($_GET['edit'], $dbh);
        $steps = Step::findAllSteps($dbh, $_GET['edit']);
        $ingredients = Ingredient::findAllIngredients($dbh, $_GET['edit']);
        $editRecipe = 1;
        require_once "views/edit_recipe.php";
        die;
    }
}
// Route 1: user comes here to add a new recipe, show them a blank form
// Route 2: user comes here to edit a specific recipe
//   (you'll need to grab that id from the query string)
// Route 3a: user entered a new recipe details and is trying to save it
//   create an object, set values, validate and save, just like in the lab
//   if all is well, send to ShowRecipe to see the added recipe
//   otherwise, back to the edit view with errors!
// Route 3b: user updated an existing recipe details and is trying to save it
//   create an object, inflate to the proper id, update values, validate and save
Example #3
0
 function getSteps()
 {
     $steps = Step::findAllSteps($dbh, $recipe_id);
     return $steps;
 }