Pain!

Imagine... Imagine a file with about four thousand lines (yep, that's right, 4000). There, you will find such gems like the following. Note that I've grepped out the "if" statements, as the content in each block is trivial (puts together a single variable). For illustration, look at the first and last entry block to get an idea what the code does.

And here we go:

if(!empty($searchSubject) && empty($searchLevel) && empty($searchProfile) && empty($searchCountry) && empty($searchVertical) ) {
   $concat='( partnersMain.subject like "'.'%'.$searchSubject.'%'.'")';
}
elseif(empty($searchSubject) && !empty($searchLevel)  && empty($searchProfile) && empty($searchCountry) && empty($searchVertical)) {
elseif(empty($searchSubject)  && empty($searchLevel) && !empty($searchProfile) && empty($searchCountry) && empty($searchVertical)) {
elseif(empty($searchSubject) && empty($searchLevel) && empty($searchProfile) && !empty($searchCountry) && empty($searchVertical)) {
elseif(empty($searchSubject) && empty($searchLevel) && empty($searchProfile) && empty($searchCountry) && !empty($searchVertical)) {
elseif(!empty($searchSubject) && !empty($searchLevel) && empty($searchProfile) && empty($searchCountry) && empty($searchVertical)) {
elseif(!empty($searchSubject) && empty($searchLevel) && !empty($searchProfile) && empty($searchCountry) && empty($searchVertical)) {
elseif(!empty($searchSubject) && empty($searchLevel) && empty($searchProfile) && !empty($searchCountry) && empty($searchVertical)) {
elseif(!empty($searchSubject) && empty($searchLevel) && empty($searchProfile) && empty($searchCountry) && !empty($searchVertical)) {
elseif(empty($searchSubject) && !empty($searchLevel) && !empty($searchProfile) && empty($searchCountry) && empty($searchVertical)) {
elseif(empty($searchSubject) && !empty($searchLevel) && empty($searchProfile) && !empty($searchCountry) && empty($searchVertical)) {
elseif(empty($searchSubject) && !empty($searchLevel) && empty($searchProfile) && empty($searchCountry) && !empty($searchVertical)) {
elseif(empty($searchSubject) && empty($searchLevel) && !empty($searchProfile) && !empty($searchCountry) && empty($searchVertical)) {
elseif(empty($searchSubject) && empty($searchLevel)  && !empty($searchProfile) && empty($searchCountry) && !empty($searchVertical)) {
elseif(empty($searchSubject) && empty($searchLevel)  && empty($searchProfile) && !empty($searchCountry) && !empty($searchVertical)) {
elseif(!empty($searchSubject) && !empty($searchLevel)  && !empty($searchProfile) && empty($searchCountry) && empty($searchVertical)) {
elseif(!empty($searchSubject) && !empty($searchLevel)  && empty($searchProfile) && !empty($searchCountry) && empty($searchVertical)) {
elseif(!empty($searchSubject) && !empty($searchLevel)  && empty($searchProfile) && empty($searchCountry) && !empty($searchVertical)) {
elseif(!empty($searchSubject) && empty($searchLevel)  && !empty($searchProfile) && !empty($searchCountry) && empty($searchVertical)) {
elseif(!empty($searchSubject) && empty($searchLevel)  && !empty($searchProfile) && empty($searchCountry) && !empty($searchVertical)) {
elseif(!empty($searchSubject) && empty($searchLevel)  && empty($searchProfile) && !empty($searchCountry) && !empty($searchVertical)) {
elseif(empty($searchSubject) && !empty($searchLevel)  && !empty($searchProfile) && !empty($searchCountry) && empty($searchVertical)) {
elseif(empty($searchSubject) && !empty($searchLevel)  && empty($searcProfile) && !empty($searchCountry) && !empty($searchVertical)) {
elseif(empty($searchSubject) && !empty($searchLevel)  && !empty($searcProfile) && empty($searchCountry) && !empty($searchVertical)) {
elseif(empty($searchSubject) && empty($searchLevel)  && !empty($searchProfile) && !empty($searchCountry) && !empty($searchVertical)) {
elseif(!empty($searchSubject) && !empty($searchLevel)  && !empty($searchProfile) && !empty($searchCountry) && empty($searchVertical)) {
elseif(!empty($searchSubject) && !empty($searchLevel)  && !empty($searchProfile) && empty($searchCountry) && !empty($searchVertical)) {
elseif(!empty($searchSubject) && empty($searchLevel)  && !empty($searchProfile) && !empty($searchCountry) && !empty($searchVertical)) {
elseif(!empty($searchSubject) && !empty($searchLevel)  && empty($searchProfile) && !empty($searchCountry) && !empty($searchVertical)) {
elseif(empty($searchSubject) && !empty($searchLevel)  && !empty($searchProfile) && !empty($searchCountry) && !empty($searchVertical)) {
elseif(!empty($searchSubject) && !empty($searchLevel)  && !empty($searchProfile) && !empty($searchCountry) && !empty($searchVertical)) {
   $concat='(
           partnersMain.subject like "'.'%'.$searchSubject.'%'.'" AND
           partnersLevel.category_id = "'.$searchLevel.'" AND
           partnersProfile.category_id= "'.$searchProfile.'" AND
           partnersCountry.category_id="'.$searchCountry.'" AND
           partnersVertical.category_id like "'.$searchVertical.'"
           )';
}