| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
Sometimes killing is the only solution to a programmer. This one is on the firing list.
|
|
Cause you never know when basic SQL syntax will change...
|
|
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.
|
|
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.
|
|
Criteria $comment = new Criteria();
$comment->add("What"); $comment->space(); $comment->add("the"); $comment->space(); $comment->add("fuck?"); print $comment->toString(); |
or the value of " ". |
|
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 "¤" ...
|
|
I suppose I'm ruining the fun by pointing out that the supplied code doesn't generate the example SQL string...
|
Not really, because then you'd have to do a global search and replace changing "leftParenthesis" to "funnyThing". |
|
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. |
|
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") AND `available` = "1" order by startDateTime; assuming getToday() returned a string representation of today. |
|
I ask because I need to make sure I'm using that class right
|
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". |
|
He didn't even pick an appropriate name for his "Criteria" class. Rubbish.
|
|
With so many levels of unnecessary modularization (given that there's no "
class EscapeMySuperiorCriteria extends Criteria { ... }" 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.
|
|
[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? |
|
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? |
|
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?
|
I agree! In case we ever get a postfix sql engine... select * from someTable where field1 6 = field2 3 * 12 = and |
The relevant clause is "similar to"... If you wanted to comment on typos in the article, I'd suggest starting with the inconsistent "equal()"/"equals()", and work up from there. |
|
Genius! I have the perfect project for this utility class. Thank you for the code sample!
|
|
Looks like cargo cult.
|
:P |
|
He was ahead of his time, it's an early version of LINQ. Intellisense and everything! Genius!
|
|
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?! |
|
AND TO ADD To my extreme disbelief, apparently the rest of you knuckleheads don't know it's Propel either.
Good god. |
|
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. |
Re: Simple SQL
2009-06-15 09:53
•
by
Anonymous Coward
(unregistered)
|
where field1 6 = field2 3 12 * = and ? |
|
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" ™ |
Perhaps he had Irish-Girl on his mind... |
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() |
Re: IT'S PROPEL!
2009-06-15 10:00
•
by
Crafty_Shadow
(unregistered)
|
Did you read the article at all? This IS NOT the Propel Criteria object even though it's trying to look like it. Read. |
Trnslating my postfix into infix for you... where (field1 = 6) and (field2 * 3 = 12) |
True, we must support our mid and far eastern friends with full unicode support as well! |
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* |
RTFWTF. A hint: the dev is NOT using Propel...
With a 99% certainty, that's exactly what happened. |
Re: Simple SQL
2009-06-15 10:12
•
by
configurator
(unregistered)
|
prefix is much better! where and = field1 6 = * field2 3 12 |
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. |
Are you referring to Buddy or Ms. Hunter? |
Ilex opaca or Ilex aquifolium? |
Wow, that's so full of WIN I couldn't keep reading without commenting. And if it's not full of WIN, then the sarcasm at least makes it full of LULZ. kthxbye |
Would you just shut up already? This ISN'T Propel, end of story. No prizes for guessing where the coder's "inspiration" came from but it doesn't change the fact that this is not Propel so you're just talking rubbish. Instead of ranting about the very first line, why not go back to the article and read the rest of it? |
Re: Simple SQL
2009-06-15 11:07
•
by
Mr. A. T. Roll
(unregistered)
|
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! |
|
We don't use Propel. This class was custom-built.
|
|
He was lazy to add new functions for ordering definition...
|
If only you knew. |
Re: Simple SQL
2009-06-15 11:33
•
by
WhatTheFrank
(unregistered)
|
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. |
Re: IT'S PROPEL!
2009-06-15 11:49
•
by
Stephen Melrose
(unregistered)
|
|
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?! |
Re: Simple SQL
2009-06-15 11:50
•
by
Stephen Melrose
(unregistered)
|
Propel is a lot better than what this guy has demonstrated. Give it a go before you knock it. Makes development a hell of a lot easier. Also Doctrine is another very good PHP ORM. |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |