• 'Sam 'Smith (unregistered) in reply to dogmatic
    dogmatic:
    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!
  • 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....

  • Bilongda (unregistered) in reply to Cbuttius
    Cbuttius:
    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?
  • Whosdr (unregistered)

    Sorry I'm off-topic, but I just got this in a captcha.

    [image]
  • phillipe (unregistered) in reply to Meep
    Meep:
    Ouhlala:
    ///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....

  • phillipe (unregistered) in reply to da Doctah
    da Doctah:
    foo:
    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.
    WHAT?!

    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.

    Oui

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

  • (cs) in reply to Moi
    Moi:
    but being hideously bad at english is a common quirk of {$NATIONALITY} software engineer ...

    FTFY.

  • Doctor_of_Ineptitude (unregistered) in reply to qeury farie
    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.

  • 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.

  • (cs) in reply to Nagesh
    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 DB.inc, Object.inc, and PickList.inc. (FYI I work alone, not on a team. YMMV)
  • (cs)

    Mistype $qeury once; every time after that it's $q<letautocompletedotherestforme>.

  • qwz (unregistered) in reply to henke37
    henke37:
    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?

  • (cs) in reply to Jabba the Hutt
    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.

  • 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.

  • big picture thinker (unregistered) in reply to no laughing matter
    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!
    [/url].
    Yes he actually does say that if you scroll down...
  • 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

  • (cs)

    Gee, he's invented everything, inclueding his own kewl turmenology.

  • nico (unregistered) in reply to 'Sam 'Smith

    You 'Sir, ju'st made my day.

  • Vincent (unregistered)

    TRWTF is that drupal's codebase isn't much better than that

  • SQL Vader (unregistered)

    I have wrapped your mysql lib. Pray I don't wrap it any further.

  • John (unregistered) in reply to Dave

    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.

  • 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.

    Sigh.

  • noone (unregistered) in reply to iWantToKeepAnon

    Except he was paid for this code so the newb defense is invalid.

  • Thomas (unregistered) in reply to Brian
    Manadar:
    /* You fail */ SELECT 1 + 1

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

    Brian:
    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.

  • (cs) in reply to Jimmee
    Jimmee:
    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.
  • Richard (unregistered)

    I just fixed a bug in another part of the application.

    Because

            $query = "SELECT `worked_hours_id`
                FROM `worked_hours`
                WHERE
                    `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.

Leave a comment on “The MySQL Wrapper Wrapper”

Log In or post as a guest

Replying to comment #:

« Return to Article