Comment On The MySQL Wrapper Wrapper

Hey Pittsburgh Readers – I'll be in town this weekend, so who's up for grabbing a couple drinks tomorrow, Friday (July 13) Night at Market Square? Mark, Remy, and I will be there -- just drop me a line and we'll catch up. Oh, and I'll make sure to bring a TDWTF Mug for you if you’d like one (just let me know). [expand full text]
« PrevPage 1 | Page 2Next »

Re: The MySQL Wrapper Wrapper

2012-07-12 17:35 • by 'Sam 'Smith (unregistered)
384994 in reply to 384970
framework's are like learning a new language
Thi's i's 'so true! 'So many folk's 'suppo'se language i's 'simple. 'Still, if there i's 'some trivial 'syntax rule you mi's's, or ju'st don't under'stand, you end up looking 'so 'stupid!

Re: The MySQL Wrapper Wrapper

2012-07-12 18:11 • by Someone, but not the other someone (unregistered)
Uhm....(leaving aside the rest of this WTF) the last comment about the consistent misspelling of Query....
While it grates me to see qeury instead of query, one of the most important principles of readable code is consistency (more important to be consistent than correct in choosing conventions and variable names). If anything, this at least is a good thing....

Re: The MySQL Wrapper Wrapper

2012-07-12 18:14 • by Bilongda (unregistered)
384996 in reply to 384943
the way the weather is here in London you wouldn't think it was July or June. More like March or April

Er...I thought London only had two weather patterns anyway...."Raining" and "about to rain" - which one is the March or April one?

Re: The MySQL Wrapper Wrapper

2012-07-12 18:20 • by Whosdr (unregistered)
Sorry I'm off-topic, but I just got this in a captcha.

Re: The MySQL Wrapper Wrapper

2012-07-12 18:20 • by phillipe (unregistered)
384998 in reply to 384968
///loop through the result and full the array

It does not make any sense in english. But it is a blind idiot translation of the french phrase. Maybe other language too, but being hideously bad at english is a common quirk of french software engineer, since english comment are mandatory but there is no other reason to learn english.

Actually, I'm going to go on a limb and say that you are French yourself and you believe that the word the guy wanted to use is "remplir" (fill in English); however, I would think it is more likely to be a typo in this case: see how the U is close to the I on your keyboard and it becomes
///loop through the result and fill the array

which is perfectly goo.. err, OK English... :)

Okay? Aside from dropping punctuation and capitalization, that is perfect American Standard English. All of the comments are fragments without capitalization or punctuation, which is appropriate for comments. As far as fragments can be, they're grammatically perfect. The misspellings all look like typos, except dubble* looks like a learned mistake, he probably inferred it (quite logically) from bubble. Most people have that; I can't, for some reason, get "receive" right without checking it, and always want to pronounce the 'ch' in "chimera" as a "sh".
It's funny how on auto-pilot you can make silly mistakes like that....if I'm a little distracted, I often replace A with 8 and vice-versa. Sort of illogical, given other than the sound they are nothing alike, and yet the brain seems to do that sometimes....

Maybe I gotta give up C and go PHP if my brain is failing me....

Re: The MySQL Wrapper Wrapper

2012-07-12 18:27 • by phillipe (unregistered)
384999 in reply to 384985
da Doctah:
Actually, this kind of misspelling (confusion of vowels) is more typical of English speakers, esp. American English, where all vowels are pronounced more or less the same.

Did you never read Peter Benchley's article on how to speak French? With its table of French vowels for handy reference:

"a" -> pronounced -> "ong"
"e" -> pronounced -> "ong"
"i" -> pronounced -> "ong"
"o" -> pronounced -> "ong"
"u" -> pronounced -> "ong"

Add to this the impossible-to-ignore fact that all French consonants are silent, and the profusion of flyspecks that sprout from every letter. (Most French people don't even realize that the Vietnamese, their former colonials, have perpetrated a hilarious satire on the latter, with an average of 3.2 accent marks per letter.)

Foriegn spelling is wierd.

"Damn Foreigners - can't go anywhere in the world without meeting any" - Antony Aloysius St. John Hancock.

Re: The MySQL Wrapper Wrapper

2012-07-12 22:42 • by oheso
385002 in reply to 384957
but being hideously bad at english is a common quirk of {$NATIONALITY} software engineer ...


Re: The MySQL Wrapper Wrapper

2012-07-12 23:32 • by Doctor_of_Ineptitude (unregistered)
385003 in reply to 384933
qeury farie:
I post again to agree. captcha = dolor. My custom CMS will make me a lot of dolor.

Qeury Farie, I like you. You are a lot more tolerable than Fake Nagesh and his sock puppets and their sock puppets. As a fake Indian I become bored of all the garbage that Nagesh has spewed. Thanks for being a being of incorrect spelling but somewhat correct grammar.

Captcha:populus. I hope you are populus too.

Re: The MySQL Wrapper Wrapper

2012-07-13 01:13 • by Brian (unregistered)
I'm clearly very very far in the minority on this, but depending on what kinds of places it's used, I'm kind of okay with the function's return value changing.

The alternative is to always return an array of arrays, and then to unwrap it after every use that expects a single row. (I can't think of many good options here, other than selecting the most recent x by ordering and limiting 1?)

When you're doing that, and your query fits your expected pattern, unwrapping the single result is not the most horrible thing to do.

Yes, it would be better to just have an overload like query_single that unwraps it for you, but for something you knock out quick, because you DON'T want to build an entire framework.. I don't see anything egregious about this.

Re: The MySQL Wrapper Wrapper

2012-07-13 02:31 • by AndyCanfield
385005 in reply to 384974
There are no bad languages. Bad programmers only. and bad programmers can ruin good language like java also, so PHP is not exception to this.

I am tired of the anti-PHP thunder. I code in PHP because it's better than the alternatives (C, C++, Java). The anti-PHP pages talk about weird syntax, but you don't need that syntax and live without it. Sure I've got wrappers; about 15,000 lines of wrappers that I've developed over ten years and re-use constantly, including,, and
(FYI I work alone, not on a team. YMMV)

Re: The MySQL Wrapper Wrapper

2012-07-13 03:33 • by Watson
Mistype $qeury once; every time after that it's $q<letautocompletedotherestforme>.

Re: The MySQL Wrapper Wrapper

2012-07-13 04:16 • by qwz (unregistered)
385007 in reply to 384929
I don't see the issue. Sure there was a misspelling. And sure the comments might be incorrect.

But it has logic behind it and no insane syntax tricks. The code is fine.

What if the first word in your select query is WITH?

Re: The MySQL Wrapper Wrapper

2012-07-13 04:25 • by beginner_
385008 in reply to 384962
Jabba the Hutt:

He was creating his own CMS; he obviously can't use someone else's framework because the superiority of his own is his competitive advantage. Mandatory Joel link.

Don't know what to think of a guy that was responsible for a language that opens modal dialogs to show "compiler" errors.

Re: The MySQL Wrapper Wrapper

2012-07-13 08:54 • by radarbob (unregistered)
Waving the BS Flag on all the "kudos for recognizing the need for a PHP SQL wrapper."

I know bupkis about PHP but after 2 minutes reading this I can say convincingly "Well, everyone knows PHP needs a good SQL wrapper."

This "nice try" is a true WTF because a) it is crap yet 2) he put it into production on a "paid gig" which means d) he's unprofessional, incompetent, and probably dyslexic.

Re: The MySQL Wrapper Wrapper

2012-07-13 16:32 • by big picture thinker (unregistered)
385054 in reply to 384982
no laughing matter:

Well there is one good advice in there:
Joel Spolsky:
If it's a core business function -- do it yourself, no matter what.

Unfortunately the advice that is missing is:
not Joel Spolsky:
If it's not a core business function and there are mature, tested solutions available -- don't do it yourself, or your code will be the real WTF!

Yes he actually does say that if you scroll down...

Re: The MySQL Wrapper Wrapper

2012-07-13 18:16 • by the irritainer (unregistered)
Trfwtf is not that its php or that the code is that bad. Im not saying its great either but this codemonkey at least understands the basic principles on how to deal with queries. Ive seen way worse...

The real wtf is the submitter for not doing a code review during the interview. Php is a powerfull language in hands of those who know what theyre doing!

Captcha: i typed this from my new tab, sorry for spelling errors

Re: The MySQL Wrapper Wrapper

2012-07-13 23:48 • by Coyne
Gee, he's invented everything, inclueding his own kewl turmenology.

Re: The MySQL Wrapper Wrapper

2012-07-14 03:55 • by nico (unregistered)
385071 in reply to 384994
You 'Sir, ju'st made my day.

Re: The MySQL Wrapper Wrapper

2012-07-14 09:15 • by Vincent (unregistered)
TRWTF is that drupal's codebase isn't much better than that

Re: The MySQL Wrapper Wrapper

2012-07-14 16:39 • by SQL Vader (unregistered)
I have wrapped your mysql lib. Pray I don't wrap it any further.

Re: The MySQL Wrapper Wrapper

2012-07-16 03:05 • by John (unregistered)
385097 in reply to 384955
Did you ever stop to think that maybe this was wrote before PDO or the prevalence of frameworks? There was a point in time where you pretty much had to if you wanted something sane to work with. However, if this was wrote in the last several years I'll agree with you. Even if it wasn't the developer needs to be slapped for doing such a shitty job.

Re: The MySQL Wrapper Wrapper

2012-07-16 17:21 • by iWantToKeepAnon (unregistered)
This isn't WTF code, this is newb code. Sure it's bad, but not WTF. I've noticed almost all the code snippets recently are not WTF, just bad ... not evil bad. This list is turning into experts looking down their noses at the less advanced programmer.

Sure a lot of these bad programmer think "mine will be better", but that shows (misplaced) confidence.


Re: The MySQL Wrapper Wrapper

2012-07-17 11:39 • by noone (unregistered)
385195 in reply to 385119
Except he was paid for this code so the newb defense is invalid.

Re: The MySQL Wrapper Wrapper

2012-07-31 09:50 • by Thomas (unregistered)
385973 in reply to 385004
/* You fail */ SELECT 1 + 1

(SELECT 1 + 1) UNION (SELECT 1 - 1)

When you're doing that, and your query fits your expected pattern, unwrapping the single result is not the most horrible thing to do.

But if won't work as you'd expect with LIMIT 5,1.

Re: The MySQL Wrapper Wrapper

2012-08-08 22:46 • by Daniel15
386776 in reply to 384932
There is nothing inherently wrong with creating a wrapper around the PHP mysql functions, indeed, done right it's pretty essential in the manner of creating an abstraction layer to allow you to create a lot of convenience and safety - even if you never forsee using anything except mysql.

Except a wrapper already exists and is built-in to PHP. It's called PDO.

Re: The MySQL Wrapper Wrapper

2013-06-13 12:25 • by Richard (unregistered)
I just fixed a bug in another part of the application.


$query = "SELECT `worked_hours_id`
FROM `worked_hours`
`wh_date` = '" . $thisDay . "'
AND `display_row` = " . $rowID . "
AND `users_id`=" . $userid . "
LIMIT 1;";
$result = $mysql->query($query);

if ( isset($result->worked_hours_id) )
// real important stuff here

did not trigger the if() statement because

if(substr( strtolower($qeury) ,-7) == 'limit 1' && $resultArray){
$resultArray = $resultArray[0];

did not trigger because of the f*cking semicolon at the end of the query. Ehr qeury.
I'm going to cry in a corner now.
« PrevPage 1 | Page 2Next »

Add Comment