I'm smrt.
I like to laugh at clever programmers that outsmart themselves. An anonymous user sent in the following.
<?php
/* query_fetch - a very smart function.
It executes and fetches sql data, returning either a value, an array,
or a multidimensional array depending on the query results
*/
function query_fetch ($query,$start=1,$max=1000)
{
...
}
?>
The WTF is what query_fetch()
returns. Depending on what comes back from the database it returns a single value (1 row, 1 column), an array (1 row, multiple columns), or a multi-dimensional array (multiple rows and columns). Cool right? A single function that does all that... ohh very smart.
This function is pretty dumb ass because it might return a scalar one time and an array the next. But who the fuck cares that debugging becomes a nightmare, or that I have to write extra code?! It'll make me look smart and nothing like shows smart like adding unnecessary complexity and requirements!
Yea it's a pain in the ass that sometimes a scalar pops out and fucks up the code. The solution? Write a smarter function!
<?php
function fixate($item) {
if (($item)&&(!is_array($item))){ return(array(0=>$item)); }
return($item);
}
?>
From a WTF to an OMG WTF! Fixer functions are so damn wrong! They don't solve the original problem, they add more complexity and they make the original problem worse. They do make you look smarter though and that's what's important! Look how I solved that data ambiguity problem! Aren't I clever?
/sarcasm.