Doc #54618 [NEW]: bindValue always returns true

From: Date: Thu, 28 Apr 2011 07:06:17 +0000
Subject: Doc #54618 [NEW]: bindValue always returns true
Groups: php.doc.bugs php.doc.bugs 
Request: Send a blank email to doc-bugs+get-6306@lists.php.net to get a copy of this message
From: Operating system: PHP version: 5.3.6 Package: PDO related Bug Type: Documentation Problem Bug description:bindValue always returns true Description: ------------ even if you $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); the function bindValue (at least with MySQL driver) will not help you detect any type errors, duplicated calls, or binding to wrong parameter. Test script: --------------- Bellow is a part of my PHPUnit tests that confirm this ( i guess you can figure out that getSUT, gets system under tests, that is prepares a query from PDO object connected to MySQL database): <?php public function testBindValueAlwaysReturnsTrue(){ $s = $this->getSUT("SELECT 1 FROM users WHERE id=:id"); //this one is ok: $this->assertSame(true,$s->bindValue(':id',1,PDO::PARAM_INT)); //this one is not ok at all, as '1' is not integer. //moreover we already bound id $this->assertSame(true,$s->bindValue(':id','1',PDO::PARAM_INT)); //this is also bad to allow both :id and id $this->assertSame(true,$s->bindValue('id',1,PDO::PARAM_INT)); //1 is not a string $this->assertSame(true,$s->bindValue('id',1,PDO::PARAM_STR)); //'a' is not an integer $this->assertSame(true,$s->bindValue('id','a',PDO::PARAM_INT)); //null is surely not an integer: $this->assertSame(true,$s->bindValue('id',null,PDO::PARAM_INT)); //1 is not a null $this->assertSame(true,$s->bindValue('id',1,PDO::PARAM_NULL)); //13 is not a valid type of parameter $this->assertSame(true,$s->bindValue(':id',1,13)); //'atlantis' is not even mentioned in the SQL query string: $this->assertSame(true,$s->bindValue(':atlantis',1,PDO::PARAM_INT)); } ?> Expected result: ---------------- I would expect either more precise documentation which would list all cases for which bindValue returns false (I could not find any), or fixing the function, to return false in cases mentioned above. Actual result: -------------- function returns true whatever I do. -- Edit bug report at http://bugs.php.net/bug.php?id=54618&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54618&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54618&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54618&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54618&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54618&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54618&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54618&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54618&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54618&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54618&r=support Expected behavior: http://bugs.php.net/fix.php?id=54618&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54618&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54618&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54618&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54618&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54618&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54618&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54618&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54618&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54618&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54618&r=mysqlcfg

« previous php.doc.bugs (#6306) next »