one wtf, two wtf, three wtf...ah ah ah!
Submitted by phrax on Wed, 2004-12-01 10:17.
Wonky Code
I had to confirm that this was production code. It's always more funny, or tragic, when production code is bad. Thanks to Søren for sending this in.
What's the most efficient way to skip a few numbers? Well it's not this way! It's bad enough that 2, 3 and 4 are literals and not constants, but they also represent database logic. At least they didn't select *
and skip records with the wrong TypeId's.
<?php
// ...
if($TypeId>0) {
if ($TypeId == 2) {
} else if($TypeId == 3) {
}else if($TypeId == 4) {
}
else {
$sql .= " AND D.TypeId = $TypeId";
}
}
?>