Bug #68849 [Opn->Csd]: bindValue is not using the right data type
Edit report at https://bugs.php.net/bug.php?id=68849&edit=1
ID: 68849
Updated by: ab@php.net
Reported by: php dot bohwaz at miam dot kd2 dot org
Summary: bindValue is not using the right data type
-Status: Open
+Status: Closed
Type: Bug
Package: SQLite related
Operating System: Debian Wheezy
PHP Version: 5.4.36
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e49580c96e189b3574a3cbf65d96a7173feb07f0
Log: Fixed bug #68849 bindValue is not using the right data type
Previous Comments:
------------------------------------------------------------------------
[2015-01-18 04:41:30] php dot bohwaz at miam dot kd2 dot org
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 this bug report at https://bugs.php.net/bug.php?id=68849&edit=1
Thread (2 messages)