• (disco)

    So not only didn't they consider to use PHP Data Objects, they couldn't even be bothered with prefixing their functions with db_?

    Woe be upon the one adding another function called info.

  • (disco) in reply to JBert
    JBert:
    Woe be upon the one adding another function called info.

    My thoughts exactly.

  • (disco) in reply to JBert

    Maybe it was inside an object called db?

  • (disco)

    wait a minute!

    do really php returns a list or a bool from a method?

    this is the real WTF

  • (disco) in reply to giammin
    giammin:
    wait a minute!

    do really php?

    this is the real WTF

    FTFY

  • (disco) in reply to LB_

    thanks!

  • (disco)
    JBert:
    So not only didn't they consider to use PHP Data Objects

    One of these days, when I'll be able to afford all the travel, I'm going to find the author of every newly written tutorial (and those who still maintain the site and they haven't added disclaimers to old tutorials) that uses mysql_ and/or mysqli_ functions and bludgeon them to death.

    giammin:
    do really php returns a list or a bool from a method?

    Yes. And yes, it's stupid. But not that much more stupid than shit other dynamically typed languages do. Which is not en excuse for either of them, I just kinda get annoyed that PHP tends to be the only language that gets called on it.

  • (disco)

    Looks like he was paid by the hour :P

  • (disco) in reply to adrian7
    adrian7:
    Looks like he was paid by the hourfor nothing :stuck_out_tongue:

    FTFY

  • (disco) in reply to JBert

    Not only did they not think of using PDO but evidently Remy knows nothing about it as well:

    PHP has a lot of warts, and one of those warts is its approach to database interactions. If you want to talk to a MySQL database, every function for doing it is prefixed mysql_, and for say, Postgres, you’d use functions prefixed pg_. On the other hand, it uses an object oriented approach for talking to SQLite3, while Oracle not only has a set of oci_ prefixed functions, but has to add a bunch of important functions that make it just different enough as to be difficult to switch to.

  • (disco) in reply to RFoxmich

    Remy probably knew it existed, but the point of that paragraph was to bash PHP as per usual. Can't let people forget that it's a fractal of bad design.

  • (disco)

    I am not a web developer, but perhaps someone could tell me why you want to access a database with PHP directly?

  • (disco) in reply to Helix
    Helix:
    I am not a web developer, but perhaps someone could tell me why you want to access a database with PHP directly?

    As opposed to...?

    If your site's in PHP, PHP is your back-end. Why wouldn't you access the database with it?

  • (disco) in reply to blakeyrat
    blakeyrat:
    If your site's in PHP, PHP is your back-end. Why wouldn't you access the database with it?

    But... but... if we don't use Node, Redis, Sidequik, Mongo and SQLite before we even hit MySQL / Postgres / Oracle / MSSQL we won't be webscale!


    Filed under: I kid, but tell me it doesn't genuinely feel that way lately

  • (disco)

    The Real WTF is using the mysql_* functions at all. Those things have been deprecated for years and anyone using them really ought to be taken out, shot, and then forced to eat a physical print-out of their code

  • (disco) in reply to RFoxmich
    RFoxmich:
    Not only did _they_ not think of using PDO but evidently Remy knows nothing about it as well:

    Yup, that was my initial reaction, too. I know a lot of articles are written a few days or even a few weeks before they're posted to the site, but I didn't realize that Remy sometimes writes his articles 10 years in advance.

  • (disco) in reply to Dragnslcr

    Is "doesn't know PHP all that well" really a negative, though?

  • (disco) in reply to rvleshrac

    Well, i think that if you insist on bashing PHP, at least bash it for its actual faults, not those that were patched a long time ago.

    Cause, you know, it isn't that hard.

  • (disco) in reply to kt_

    but man! haven't you read that article? fractal of something? it bashes PHP! so it must be TR :wtf:

  • (disco) in reply to Jarry

    http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

  • (disco) in reply to Ashley_Sheridan
    Ashley_Sheridan:
    The Real WTF is using the mysql_* functions at all. Those things have been deprecated for years and anyone using them really ought to be taken out, shot, and then forced to eat a physical print-out of their code
    function get_user(){
    return mysql_query("SELECT * FROM user WHERE password='"+$_POST["password"]+"'")
    }
    

    Oh wait, I forgot something...

    function real_get_user(){
    return mysql_query("SELECT * FROM user WHERE username='"+$_POST["username"]+"' AND password='"+$_POST["password"]+"'")
    }
    

    Filed Under: I feel dirty now, please help

  • (disco) in reply to sloosecannon
    sloosecannon:
    Filed Under: I feel dirty now, please help

    Better start printing the source code... :p

  • (disco) in reply to Ashley_Sheridan

    ###How to print computer program using PHP?

    Hello freinds. I have a progream that needs to print using PHP to my printer. How wuold I do that? If I type print("something.php") it doesn't print it.

  • (disco) in reply to sloosecannon

    ###Re: How to print computer program using PHP?

    Hello sloose, you could try doing it in a separate thread. Sometimes PHP is too slow for printing.

  • (disco) in reply to LB_

    ###RE: Re: How to print computer program using PHP?

    Can you give me teh codez?

    Right now I have

    <?php
    
    print("something.php")
    
  • (disco) in reply to sloosecannon

    Turing fucking damnit, I know you were just joking, but I... I can't, I just can't I have this fear some dumbass will see it and actually use it!

    If you ACTUALLY HAVE TO use mysql/mysqli extension because RAISINS:

    http://php.net/manual/en/mysqli.prepare.php

    http://php.net/manual/en/mysqli.prepare.php

    #http://php.net/manual/en/mysqli.prepare.php

    FOR THE LOVE OF ANYTHING THAT IS HOLY TO YOU, USE FUCKING PREPARE!

    Or, you know, PDO::prepare, because it's not actually utter shit.

    AFTER you disable perparation emulation because some idiot thought it would be better to do it in PHP than in the actual fucking RDBMS that knows what the fuck it's doing!

    </rant>

  • (disco) in reply to Onyx

    and where do you call msql_real_not_real_escape_string?

  • (disco) in reply to Jaloopa

    Nowhere, because you use THE FUCKING PREPARE FUNCTIONS.

    While we're talking about PHP, there is one nice thing in PDO that can fuck you over if you're not careful:

    http://php.net/manual/en/pdostatement.bindvalue.php

    http://php.net/manual/en/pdostatement.bindparam.php

    What's the difference? From bindParam docs:

    Unlike PDOStatement::bindValue(), the variable is bound as a reference and will only be evaluated at the time that PDOStatement::execute() is called.

    Sounds reasonable, yes? It's even in the docs!

    Well, yes it is, but am I crazy for thinking that, for benefit of the noobies, this stuff should be clearly marked in some fashion? Bold text, highligted block, something?

    Because it sure did bite me on the ass when I only started learning. The only reason I remember it to this day is that it took me freaking ages to find the bug. My fault? Likely. But damn it, I'd appreciate that stuff visibly marked.

  • (disco) in reply to Onyx
    [image]

    I see three links, but four click counters (the stupid bubbles with numbers). Discourse!!!

  • (disco) in reply to sloosecannon

    ###Re: How to print computer program using PHP?

    Hi sloose, I think you should be using the jquery. see:

    $ = console;
    $.log('something.php');
    

    If this does not work please send me your browser version and we may troubleshoot.


    bb36e | MSDN Technet Support Expert

  • (disco) in reply to Onyx

    you missed the :trolleybus: on @Jaloopa's post

  • (disco) in reply to Jarry

    Nah, I just wanted to vent a bit. Seemed like a good opportunity.

  • (disco) in reply to blakeyrat
    blakeyrat:
    If your site's in PHP, PHP is your back-end. Why wouldn't you access the database with it?

    Because (for the types of sites I work with), the WebServer would be publically exposed and contact a set of services (likely, but not necessarily ReST) that reside in a more secure environment which would in turn (either directly or not) contact the DB.

    Makes for a MUCH better scalability server when you need to create a garden or farm for your front ends.

  • (disco) in reply to Onyx
    Onyx:
    Well, yes it is, but am I crazy for thinking that, for benefit of the noobies, this stuff should be clearly marked in some fashion? Bold text, highligted block, something?

    Or better, call it something like bindDeferred of bindReference which makes it obvious what the difference is.

    Oh wait, this is PHP, naming things right is :doingitwrong:

  • (disco) in reply to NedFodder
    NedFodder:
    I see three links, but four click counters (the stupid bubbles with numbers). Discourse!!!

    Programming today is a race between PHP engineers building to strive bigger and better idiot-proof fractals, and the Discodevs trying to produce bigger and better WTFs. So far, the Discodevs are winning.

  • (disco) in reply to chubertdev

    +discourse_real_bake_post()

  • (disco) in reply to sloosecannon

    Right? I'm pretty much sure my thought process at the time was:

    • I need to bind parameters to this prepared statement
    • hey, Google, how to I bind parameters to a PDO statement in PHP?
    • oh, bindParam, sounds reasonable... yup, that works! Intuitive name, too! Thanks, Google and PHP docs!
    • ok, need two queries for this thing... so... bind this.. and what do I stick this value into... eh, might as well just stick it in this generic reusable temp variable, it's useless as it is at this point anyway...
    • ... and now just execute the queries...
    • GRALBRARGH! WHY U SEND WRONG PARAMETERS FOR QUERY?

    Note: I was probably doing something stupid at the time. The most stupid thing I did was assume PHP is smart, though.

  • (disco) in reply to Onyx

    The internet really needs some kind of expiration method. Google seems to give weight to things that have been around a while, which makes sense for certain things, but not for others.

    The stack overflows of the world need to do a better job letting people know what is bad or outdated advice besides a comment from someone 5 under the wrong answer with 432 upvotes.

  • (disco) in reply to TheCPUWizard
    TheCPUWizard:
    Because (for the types of sites I work with), the WebServer would be publically exposed and contact a set of services (likely, but not necessarily ReST) that reside in a more secure environment which would in turn (either directly or not) contact the DB.

    Why stop there?

    Better have that REST service call other REST services. Just in case. In fact, better add another layer or two. Make sure as much pointless, stupid code gets between the user and their data as possible.

  • (disco) in reply to vita10gy

    https://what.thedailywtf.com/t/sigh-why-do-i-even-try-a-novlet-on-stackoverflow/51280/

  • (disco) in reply to Onyx

    I could see that coming up in a for loop type thing... You end up inserting the same thing 10,000 times rather than 10,000 different things

  • (disco) in reply to sloosecannon

    I love how Discourse randomly gave me a linked post notification for this despite you not linking to one of my posts.

  • (disco) in reply to sloosecannon

    It was probably something like that, yes.

    These days I just use bindValue 99.9% of the time, because bindParam behaving the way it does is very rarely actually useful (IMHO) unless it's some kind of stylistic choice (write query and bindings in one block, then handle values, then just call execute, for example).

  • (disco) in reply to powerlord

    Actually I did, originally. Because copying from /u/topics gives you the "last post" link, not the "op" link. Because :raisins:

    Then I :hanzo: edit'd the link to point to the OP :P

    Now, why Discourse still sends notifications within the :hanzo: edit period? Who tf knows...

  • (disco) in reply to Onyx
    Onyx:
    Yes. And yes, it's stupid.

    PHP has several functions that can return 0 or false, which mean different things, but 0 == false.

  • (disco) in reply to ben_lubar
    ben_lubar:
    Onyx:
    Yes. And yes, it's stupid.

    PHP has several functions that can return 0 or false, which mean different things, but 0 == false.

    Psh, why would you ever need to differentiate the two?

  • (disco) in reply to blakeyrat

    I saw a job ad that wanted proficiency in the following four fields:

    • PHP
    • node.js
    • MySQL
    • MongoDB

    I'm not sure what they're making, but why the fuck do they need all four of those things?

  • (disco) in reply to ben_lubar
    ben_lubar:
    I saw a job ad that wanted proficiency in the following four fields:
    • PHP
    • node.js
    • MySQL
    • MongoDB

    I'm not sure what they're making, but why the fuck do they need all four of those things?

    They need to write their entire db and system twice for redundancy purposes. Obviously. That's how you make fallback servers, right?

  • (disco) in reply to sloosecannon

    I'm actually torn on whether I like it in some cases or not.

    For example, strpos returns 0 if substring is found at the beginning of the string, FALSE if substring is not found. C would return -1 in place of FALSE.

    So... on one hand it's a clear distinction and if(strpos($string, $substring) === FALSE) looks nicer than if(strpos($string, $substring) === -1)

    But... mixing booleans and integers...

  • (disco) in reply to Onyx

    Yeah. It makes sense, if you know how it works. But it's so crazily error prone, and not-newb friendly. And PHP has a LOT of newbs

Leave a comment on “All Wrapped Up”

Log In or post as a guest

Replying to comment #:

« Return to Article