public static function getBySearch($str) { global $db; $sql = "SELECT * FROM ingredients WHERE name LIKE ?"; $values = array("%" . $str . "%"); $res = $db->qwv($sql, $values); return Ingredient::wrap($res); }
public static function getRecommendedByItem($id) { global $db; //get all ingredients recommended for the item $recommendedSQL = "SELECT * FROM items_have_recommended_ingredients WHERE itemid=?"; $values = array($id); $recList = $db->qwv($recommendedSQL, $values); //get info for each ingredient $recommendedSQL = "SELECT * FROM ingredients WHERE ingredientid=?"; $recommends = array(); $db->prep($recommendedSQL); foreach($recList as $recID) { $values = array($recID['ingredientid']); $ing = $db->qwv(null, $values); array_push($recommends, $ing[0]); } return Ingredient::wrap($recommends); }