function recipe_get_nodes_for_ingredients in Recipe 6
Get recipes that have these ingredients.
Return value
A database query result suitable for use the node_title_list.
1 call to recipe_get_nodes_for_ingredients()
- recipe_ingredient_index_page in ./
recipe_ingredient_index.inc - @file recipe_ingredient_index.inc - This is an include file containing most all of the recipe category index page functionality.
File
- ./
recipe_ingredient_index.inc, line 113 - recipe_ingredient_index.inc - This is an include file containing most all of the recipe category index page functionality.
Code
function recipe_get_nodes_for_ingredients($ids = array()) {
if (count($ids) == 0) {
return FALSE;
}
$list = array();
$placeholders = implode(',', array_fill(0, count($ids), "%d"));
$sql = "SELECT DISTINCT n.nid, n.title, n.sticky FROM ({node} n, {recipe_node_ingredient} rni) WHERE n.nid=rni.nid AND rni.ingredient_id IN ({$placeholders}) AND n.type='recipe' AND n.status=1 ORDER BY n.sticky DESC, n.title";
$result = db_query(db_rewrite_sql($sql), $ids);
while ($node = db_fetch_object($result)) {
$list[] = $node;
}
return $list;
}