- 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
So, it's bad code done badly, and worse than that?
Admin
SQL: Here comes trouble! PHP: And we'll make it double!
Admin
Not only that, I'd say it's probably commonly done bad code done badly, which makes it worse. Most PHP "applications" would probably handle this stuff in a similar way.
Admin
Good joke, but as we know, it's all about programmer and not the language,
Admin
Agree on the error handling. And not going to even mention PHP..... But would be interested in thinking what would be believed to be a better solution that provided all of the capabilities of this...
Admin
True that. Much like a certain machine from one of my favorite songs, when it comes to bad developers "you wouldn't believe the things they do."
Which is why I referenced a quote from a pair whose incompetence is legendary. :)
Admin
Normal people during Halloween season: Watch horror movies.
Me during Halloween season: Read CodeSOD on TheDailyWTF.
Admin
This looks like one where the complexity is in the problem, not just in the code. If you have to handle a bunch of different messy cases, your code is going to be a bit messy. I.e. like TheCPUWizard commented, I "would be interested in thinking what would be believed to be a better solution that provided all of the capabilities of this."
The only alternative I can immediately imagine is having the input be one big SQL string - if you're giving the caller this much power, why not just give them SQL?
(Also, worrying about SQL injection in the front-end to an HPC cluster? Oy. Rewriting this with bind variables sounds like a huge waste of time.)
Admin
You mean similar incompetence as those in Javascript or Java? I agree. Democratization of programming is a good thing. And first tries are often painful.
Admin
I was referring to Team Rocket. The two comic relief bandits from the Pokemon series who are known for their utter incompetence (which even gets recognized in the later series by their commanders) who are renowned for announcing their attempts at stealing a little boys pet electric mouse by proudly stepping out in front of him and doing a dramatic montage with the same text.
Basically my point was that who ever did this was the Team Rocket of developers. :)
Admin
I mean, the simple answer is "use a query builder library, specifically one that manages an AST or token stream and renders it out to SQL once the query is built". This code would be much simpler if it was just describing the required query, and not also generating the text of the query at the same time. Code generation should always be a two step process: describe the code to be generated as tokens or syntax, then generate text based on that description.
Admin
The "simple" solution if you have any idea what an AST is. For somebody whose dev skills begin and end at iteration, branching, arrays, string diddling, and maybe regexes as a fancy form of string diddling, well, an AST may as well be a warp drive for all the ability those sorts of devs have to handle it.
Admin
PHP echo with \n... Been there, done that.
When I used to do PHP in an earlier decade, I always looked at the output via raw HTML, thus I always ended echo errors with \n.
PHP is like bad drugs. You've got to teach the kids to just say no.
Admin
Hey there, Author!
I just finished reading your article on The Daily WTF, and I couldn't resist dropping a comment. Your take on high-performance queries was not only informative but also incredibly amusing. I've been in the IT industry for quite some time, and I can relate to the "hair-pulling" experiences you described when dealing with poorly optimized database queries. Your writing style, laced with humor, made the topic both entertaining and educational. It's refreshing to see someone who can tackle technical subjects with such wit and charm.