Bug #68849 [NEW]: bindValue is not using the right data type

From: Date: Sun, 18 Jan 2015 04:41:31 +0000
Subject: Bug #68849 [NEW]: bindValue is not using the right data type
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190035@lists.php.net to get a copy of this message
From: php dot bohwaz at miam dot kd2 dot org Operating system: Debian Wheezy PHP version: 5.4.36 Package: SQLite related Bug Type: Bug Bug description:bindValue is not using the right data type Description: ------------ --- From manual page: http://www.php.net/sqlite3stmt.bindvalue --- bindValue seems to not be using the right data type for the value. For example most of the time integers are treated as SQLITE3_TEXT instead of SQLITE3_INTEGER. This causes some queries to fail. Test script: --------------- <?php $db = new SQLite3(':memory:'); $db->exec('CREATE TABLE test (a INTEGER); INSERT INTO test VALUES (1); INSERT INTO test VALUES (2);'); $s = $db->prepare('SELECT COUNT(*) FROM test WHERE (a+1) = ?;'); $s->bindValue(1, 2); $r = $s->execute(); echo 'Rows returned: '; echo $r->fetchArray(SQLITE3_NUM)[0]; echo "\n"; $s = $db->prepare('SELECT COUNT(*) FROM test WHERE (a+1) = ?;'); $s->bindValue(1, 2, SQLITE3_INTEGER); $r = $s->execute(); echo 'Rows returned: '; echo $r->fetchArray(SQLITE3_NUM)[0]; Expected result: ---------------- Rows returned: 1 Rows returned: 1 Actual result: -------------- Rows returned: 0 Rows returned: 1 -- Edit bug report at https://bugs.php.net/bug.php?id=68849&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68849&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68849&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68849&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68849&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68849&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68849&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68849&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68849&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68849&r=support Expected behavior: https://bugs.php.net/fix.php?id=68849&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68849&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68849&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68849&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68849&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68849&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68849&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68849&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68849&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68849&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68849&r=mysqlcfg

« previous php.bugs (#190035) next »