As developers, we have a bunch of stupendous stories about the time spent debugging legacy code. This blog is designed to highlight some of the most annoying / interesting / hair-rising / hilarious solutions of the past.
Thursday, March 27, 2014
Unconditonally loving WHERE
What if we glue the query string's segments together as a future condition string in a WHERE clause of an SQL statement, but there are no conditions set? Easy. Just substr($cond,0,-5) , today's legacy code tells. But what if it's followed by a space? No problem, check it five different times like this: if( isset($cond) && ($cond!='W') && $cond!=''). Check again right before building the query, if($cond=='W') $cond =''; .
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment