Tuesday, October 2, 2012

Lazy mysql

I fucking hate MySQL.

is it just me or do the letters 'sql' take far too long to type? They are in complete opposite ends of the keyboard and chafe my ass. Add in 'my' and you now have a word that requires you visit all compass points of your keyboard to type it. What's worse, every mysql function in php has "mysql" at the start of it!

Because I am a lazy bastard I made a little function that eases my pain.

function fetch($str){
    $q = mysql_query($str);
    $a = mysql_fetch_assoc($q);
    if(!$a){
         echo 'e: Fetch() returned an error! '.mysql_error();
         return false;
    }
    else return $a;
}

Now I can just call fetch("SELECT * FROM `my_ass` WHERE `mysql` = 'shit'"); whenever I require an array from a mysql string. I don't have to type "mysql" once!

Seriously, try typing mysql ten times fast.

No comments:

Post a Comment