Fetch extra information with tags
This commit is contained in:
parent
0e62120ecc
commit
8c04995d0b
@ -764,29 +764,23 @@ sub _get_ingredients {
|
|||||||
# Fetch the tags for the specified recipe.
|
# Fetch the tags for the specified recipe.
|
||||||
#
|
#
|
||||||
# @param recipeid The ID of the recipe to fetch the tags for.
|
# @param recipeid The ID of the recipe to fetch the tags for.
|
||||||
# @return A reference to an array of tag names on success, undef on error.
|
# @return A reference to an hash of tags on success, undef on error.
|
||||||
sub _get_tags {
|
sub _get_tags {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $recipeid = shift;
|
my $recipeid = shift;
|
||||||
|
|
||||||
$self -> clear_error();
|
$self -> clear_error();
|
||||||
|
|
||||||
my $tagh = $self -> {"dbh"} -> prepare("SELECT `t`.`name`
|
my $tagh = $self -> {"dbh"} -> prepare("SELECT `t`.`name`,`t`.`color`, `t`.`background`, `t`.`fa-icon`
|
||||||
FROM `".$self -> {"settings"} -> {"database"} -> {"recipetags"}."` AS `rt`
|
FROM `".$self -> {"settings"} -> {"database"} -> {"recipetags"}."` AS `rt`,
|
||||||
`".$self -> {"settings"} -> {"database"} -> {"tags"}."` AS `t`
|
`".$self -> {"settings"} -> {"database"} -> {"tags"}."` AS `t`
|
||||||
WHERE `t`.`id` = `rt`.`ingred_id`
|
WHERE `t`.`id` = `rt`.`tag_id`
|
||||||
AND `rt`.`recipe_id` = ?
|
AND `rt`.`recipe_id` = ?
|
||||||
ORDER BY `t`.`name`");
|
ORDER BY `t`.`name`");
|
||||||
$tagh -> execute($recipeid)
|
$tagh -> execute($recipeid)
|
||||||
or return $self -> self_error("Tag lookup for '$recipeid' failed: ".$self -> {"dbh"} -> errstr());
|
or return $self -> self_error("Tag lookup for '$recipeid' failed: ".$self -> {"dbh"} -> errstr());
|
||||||
|
|
||||||
# No easy way to fetch a flat list of tags, so do it the mechanistic way...
|
return $tagh -> fetchall_arrayref({});
|
||||||
my @tags = ();
|
|
||||||
while(my $tag = $tagh -> fetchrow_arrayref()) {
|
|
||||||
push(@tags, $tag -> [0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return \@tags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user