The problem you are trying to solve can be expressed as "are there any lines with type = X whose name contains the text Y?"
, , PHP. , , . , , PHP, , , , . . , SQL , , PHP-.
public function isRecipeType($ingredients, $type)
{
$sql = "SELECT COUNT(*) AS c ".
"FROM table ".
"WHERE type = ? ".
" AND ? LIKE CONCAT('%', name, '%')";
$rows = execute($sql, $type, $ingredients);
$row = $rows[0];
return $row["c"] > 0;
}
MySQL, , SQL
" AND ? LIKE '%' || name || '%'";
execute , , , , , - .
, , type. : ( ), LIKE.
, , 10% , (.. ) , , . , , , .