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 =''; .

No comments:

Post a Comment