Begin work on retrieval of recipe data
This commit is contained in:
parent
e9de229605
commit
ed279cb3cf
@ -231,6 +231,23 @@ sub set_status {
|
||||
}
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Recipe retrieval
|
||||
|
||||
sub get_recipe {
|
||||
my $self = shift;
|
||||
my $recipeid = shift;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
sub find {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Private methods
|
||||
|
||||
@ -299,8 +316,8 @@ sub _add_recipe_ingredients {
|
||||
# Add the specified tags to a recipe.
|
||||
#
|
||||
# @param recipeid The id of the recipe to add the tags to.
|
||||
# @param tags A string containing a comma-delimited list of tags, or a reference to an
|
||||
# array of tag names.
|
||||
# @param tags A string containing a comma-delimited list of tags, or a
|
||||
# reference to an array of tag names.
|
||||
# @return true on success, undef on error
|
||||
sub _add_recipe_tags {
|
||||
my $self = shift;
|
||||
@ -348,6 +365,32 @@ sub _add_recipe_tags {
|
||||
}
|
||||
|
||||
|
||||
## @method private $ _get_recipe_ingredients($recipeid)
|
||||
# Fetch the ingredients for the specified recipe, along with any separators
|
||||
# in the ingredient list
|
||||
#
|
||||
# @param recipeid The ID of the recipe to fetch the ingredients for.
|
||||
# @return An arrayref of ingredient hashes on success, undef on error.
|
||||
sub _get_recipe_ingredients {
|
||||
my $self = shift;
|
||||
my $recipeid = shift;
|
||||
|
||||
$self -> clear_error();
|
||||
|
||||
my $ingh = $self -> {"dbh"} -> prepare("SELECT `ri`.*, `i`.`name`
|
||||
FROM `".$self -> {"settings"} -> {"database"} -> {"recipeing"}."` AS `ri`
|
||||
`".$self -> {"settings"} -> {"database"} -> {"recipeing"}."` AS `i`
|
||||
WHERE `i`.`id` = `ri`.`ingred_id`
|
||||
AND `ri`.`recipe_id` = ?
|
||||
ORDER BY `ri`.`position`");
|
||||
$ingh -> execute($recipeid)
|
||||
or return $self -> self_error("Ingredient lookup for '$recipeid' failed: ".$self -> {"dbh"} -> errstr());
|
||||
|
||||
return $ingh -> fetchall_arrayref({});
|
||||
}
|
||||
|
||||
|
||||
|
||||
## @method private $ _renumber_recipe($sourceid)
|
||||
# Given a recipe ID, move the recipe to a new ID at the end of the recipe
|
||||
# table. This will move the recipe and all relations involving it, to
|
||||
|
Loading…
x
Reference in New Issue
Block a user