Req #67213 [NEW]: Add PDO::PARAM_DEFAULT constant

From: Date: Tue, 06 May 2014 11:33:32 +0000
Subject: Req #67213 [NEW]: Add PDO::PARAM_DEFAULT constant
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185667@lists.php.net to get a copy of this message
From: public at gaxweb dot com Operating system: PHP version: 5.5.12 Package: PDO related Bug Type: Feature/Change Request Bug description:Add PDO::PARAM_DEFAULT constant Description: ------------ It's currently not possible to bind the SQL DEFAULT keyword to a placeholder in prepared statements like you can for NULL for example. This would be very helpful for prepared INSERTs (see test script). It'd allow for more flexible statements, since you wouldn't have to put DEFAULT into the INSERT statement ( So please add a PDO::PARAM_DEFAULT constant. I'm not sure if, the value param of the bindValue() method should actually matter. Test script: --------------- // The calories column has a default value set in the TABLE definition $sth = $dbh->prepare('INSERT INTO fruit (name, calories) VALUES(?,?)'); // This is supported: $sth->bindValue(1, null, PDO::PARAM_NULL); // This isn't, but would be helpful: $sth->bindValue(2, 'DEFAULT', PDO::PARAM_DEFAULT); $sth->execute(); // actual query executed: // INSERT INTO fruit (name, calories) VALUES(null, DEFAULT); // notice the lack of quotes around DEFAULT Expected result: ---------------- It should replace the 2nd placeholder with the literal keyword DEFAULT, and not put it in quotes. Actual result: -------------- It fails. -- Edit bug report at https://bugs.php.net/bug.php?id=67213&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67213&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67213&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67213&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=67213&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=67213&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=67213&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=67213&r=needscript Try newer version: https://bugs.php.net/fix.php?id=67213&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=67213&r=support Expected behavior: https://bugs.php.net/fix.php?id=67213&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=67213&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=67213&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=67213&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67213&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=67213&r=dst IIS Stability: https://bugs.php.net/fix.php?id=67213&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=67213&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=67213&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=67213&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=67213&r=mysqlcfg

« previous php.bugs (#185667) next »