News for hackers. Stuff that matters.
Re:PHP to deprecate MySQL extension by etherealG on Friday July 15, 2011 @12:06PM (#2767917)
resilient to what?
Re:PHP to deprecate MySQL extension by pavel_lishin on Friday July 15, 2011 @01:39PM (#2768331)
The ? ? ? example is readable when you're inserting three values; it becomes really really easy to leave off, or add on an extra, argument when you're inserting fifteen or fifty values.

Think fast: is everything in the code below correct? I've already forgotten whether I've added an extra ? or left one off, and I just typed this 30 seconds ago.

    $sth = $dbh->("INSERT INTO a_table (lorem, ipsum, dolor, sit, amet, consectetur, adipiscing, elit, donec, malesuada, purus, et, tellus, dignissim, tristique, in, ipsum, neque, ultricies, quis, hendrerit, ac, pulvinar, eget, enim)
    ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
    $sth->execute(array($lorem, $ipsum, $dolor, $sit, $amet, $consectetur, $adipiscing, $elit, $donec, $malesuada, $purus, $et, $tellus, $dignissim, $tristique, $in, $ipsum, $neque, $ultricies, $quis, $hendrerit, $ac, $pulvinar, $enim, $eget));
Re:PHP to deprecate MySQL extension by aquadoctorbob on Friday July 15, 2011 @05:14PM (#2769134)
Trick question; you've specified the `ipsum` column twice anyway. ;)
Re:PHP to deprecate MySQL extension by etherealG on Saturday July 16, 2011 @06:12AM (#2770498)
I think it's a good idea to be abstracting this away anyway. you should have some light ORM that hides actual sql statements away, that way you don't run into this problem.

also, the named version above can have query length issues I think.