- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Sometimes killing is the only solution to a programmer. This one is on the firing list.
Admin
Cause you never know when basic SQL syntax will change...
Admin
I have a friend.. who's a brilliant programmer. The only problem is, he's good at solving extremely complicated issues. But not easy ones. So he turns easy ones into complicated before solving them.
Admin
Teacher said not to use constants in your code, use objects instead. And if you absolutely have to have constants somewhere, well at least bury them where no one will ever see.
Admin
Criteria $comment = new Criteria(); $comment->add("What"); $comment->space(); $comment->add("the"); $comment->space(); $comment->add("fuck?"); print $comment->toString();
Admin
Admin
The funny fact is that the original programmer must have had a harder time using his Criteria wrapper class than just mere SQL. But at least this code will be easy to adapt when the SQL "(" becomes "¤" ...
Admin
I suppose I'm ruining the fun by pointing out that the supplied code doesn't generate the example SQL string...
Admin
Admin
There are some good reasons to use an abstraction to SQL. A direct copy of the manual process isn't one of them.
I have written an object oriented sql abstraction and I find it a joy to use, especially when writing queries with a shed load of joins and functions in them.
Admin
I'm not a php programmer, but wouldn't that return something along the lines of
SELECT * FROM bean_overtime_availability WHERE (
startDateTime
>= "06/15/2009") ANDavailable
= "1" order by startDateTime;assuming getToday() returned a string representation of today.
Admin
I ask because I need to make sure I'm using that class right
Admin
Admin
He didn't even pick an appropriate name for his "Criteria" class. Rubbish.
Admin
With so many levels of unnecessary modularization (given that there's no "
" etc.) the SQL injection possiblity still exists. How PHPish, oh forgot, OOP is so b0rken in PHP so it's not probably even possible with his "return my instance" approach.Admin
[quote user="Mark"] Not really, because then you'd have to do a global search and replace changing "leftParenthesis" to "funnyThing".[/quote] That's why a function name should say what the function does, not how it accomplishes it. Implementation may change, API must remain the same. So the function should have been named "beginNestedExpressionWithEvaluationPrecedence".[/quote]
That's way too ambiguous and inflexible. What if mathematical order of operation conventions change?
Admin
ArrayList? In PHP? Are people really that desperate to use OO?
Ararys with numeric indexes in PHP already act like Java's lists, and array_slice can be used to remove arbitrary elements by not specifying a replacement.
Is there also a PHP HashMap to do the same operations, but on arrays with named keys?
Admin
To be fair, the function's called "quote", not "quoteAndEscape"... if it escaped the string then that'd totally be a WTF since it's not only doing the thing that can be completely described by the one-word function name, right?
Admin
select * from someTable where field1 6 = field2 3 * 12 = and
Admin
If you wanted to comment on typos in the article, I'd suggest starting with the inconsistent "equal()"/"equals()", and work up from there.
Admin
Genius! I have the perfect project for this utility class. Thank you for the code sample!
Admin
Looks like cargo cult.
Admin
Admin
He was ahead of his time, it's an early version of LINQ. Intellisense and everything! Genius!
Admin
propel.phpdb.org
What a waste of an article. I would never expect in a thousand years to see Propel in a WTF, thanks to an uneducated developer - here we have one.
Jesus christ.
Sure for one simple query, write a SQL and be done with it.. but showing the Propel criteria object as part of the WTF is just ridiculous.
Propel is designed to be used for application development, certainly not for Select * from sometable where date >= now.
Your WTF would be much better read if you pointed out that the developer had went through the trouble of using a powerful database abstraction and ORM layer to execute a very simple query, but somehow I believe there's more to the story than just that simple query otherwise why would they have spent the time to fucking deploy it in the first place?
Horrible WTF.
Alex - WTF?!
Admin
AND TO ADD To my extreme disbelief, apparently the rest of you knuckleheads don't know it's Propel either.
Good god.
Admin
When I read $c = new Criteria(); I thought to myself WTF, Propel? (no pun intended), but as I actually went about reading the article I found myself uttering What In The Name Of All That Is Holly...
It seems like the developer came across the Propel implementation of Criteria at some point, and left with those vague impressions set off to build it's own... and failed miserably.
Admin
where field1 6 = field2 3 12 * = and ?
Admin
AND TO FURTHER RANT - The goddamn submitter should have KNOWN because every fucking file is prefixed with a gigantic disclaimer, license, and url to propel.phpdb.org AND a plain as day explanation of what it does. WITH FULL PHPDOC COMMENTS.
If all of that were, for some VERY strange reason, stripped from the files, THEN, perhaps MAYBE that is "TRWTF" ™
Admin
Admin
Criteria $comment = new Criteria(); $comment->n()->o()->t()->space(); $comment->g()->e()->n()->e()->r()->a()->l()->space(); $comment->e()->n()->o()->u()->g()->h()->space(); $comment->tostring()
Admin
Did you read the article at all? This IS NOT the Propel Criteria object even though it's trying to look like it. Read.
Admin
Trnslating my postfix into infix for you...
where (field1 = 6) and (field2 * 3 = 12)
Admin
Admin
There you go, good point. I honestly didnt bother to read that much because I couldn't believe in the first place that someone would submit Propel as a WTF. But it's there for a reason. Holy shit.
Why in god's name would anyone attempt to replace the Criteria object, why?! in his case he SHOULD have simply done
$SQL = "Select * from blah where date >= 'some-date' and wtf='no'"; $con = propel::getconnection('dbname') $stmt = $con->prepare($sql); $stmt->execute(); - that simply uses the PDO routines.
What a fucknut. God damn it. facepalm
Admin
RTFWTF. A hint: the dev is NOT using Propel...
With a 99% certainty, that's exactly what happened.
Admin
prefix is much better!
where and = field1 6 = * field2 3 12
Admin
I have seen one of those self-knitted "OR mappers" and had to work with it. It generated SQL in an absolutely confusing way. A funny moment was when the SQL query size limit (2^15 chars) was exceeded in one query for only one customer (an importan one, obviously...). It had been assembled like this:
Rewrote the query generator to use the IN-clause as a quick fix and then got rid of the "OR mapper".
I don't want to imply that yours is as crappy as the one I found but good OR mappers exist already.
Admin
Gloves!
Admin
Admin
Admin
And if it's not full of WIN, then the sarcasm at least makes it full of LULZ. kthxbye
Admin
Admin
Thank God I read Daily WTF. I had heard about Propel, and thought about using it today. Now I will be sure to steer absolutely clear of that piece of garbage! TYVM Daily WTF!
Admin
We don't use Propel. This class was custom-built.
Admin
He was lazy to add new functions for ordering definition...
Admin
If only you knew.
Admin
Based on your description, your friend is not a brilliant programmer. It takes a pretty shoddy programmer to be unable to solve easy problems without turning them into complicated ones. The brilliant programmers are the ones who can take extremely complicated problems and break them down into easy ones, then solve those.
Admin
I thought the exact same thing when I read this article!
However, that is not the Propel Criteria class. I honestly believe the developer has written their own, which is a WTF in itself.
But I due agree, this developer has added complication and abstraction when it is truely not needed, and further more they have written their own based on an ORM which is far better?!
Admin
Also Doctrine is another very good PHP ORM.