Bug #63244 [Opn]: PDO fetch is inconsistent with MySQL's bit column
| From: | vrana@php.net | Date: | Sat, 27 Apr 2013 16:35:19 +0000 |
| Subject: | Bug #63244 [Opn]: PDO fetch is inconsistent with MySQL's bit column | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-9763@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63244&edit=1
ID: 63244
Updated by: vrana@php.net
Reported by: juzna dot cz at gmail dot com
Summary: PDO fetch is inconsistent with MySQL's bit column
Status: Open
Type: Bug
-Package: PDO related
+Package: Documentation problem
Operating System: Ubuntu
PHP Version: 5.3.17
Block user comment: N
Private report: N
New Comment:
It's too late to fix this on the PHP level. Let me at least document it.
Previous Comments:
------------------------------------------------------------------------
[2012-10-08 23:03:12] juzna dot cz at gmail dot com
Description:
------------
Suppose MySQL database with a column of type bit(1).
Then fetching value from this column gives a binary string ("\0", "\1") in
PHP5.3
and numeric string ("0", "1") in 5.4.
I'd expect to obtain a boolean, but numeric string would be a good enough. But it
must be consistent in both PHP versions.
Test script:
---------------
$res = $connection->query("SELECT * FROM bittest");
$row = $res->fetch();
dump($row);
Assert::same(0, $row->id);
Assert::same(false, $row->flag);
$row = $res->fetch();
dump($row);
Assert::same(1, $row->id);
Assert::same(true, $row->flag);
Expected result:
----------------
// 5.3.17
Nette\Database\Row(2) {
id => 0
flag => "\00"
}
Nette\Database\Row(2) {
id => 1
flag => "\01"
}
// PHP 5.4.7
Nette\Database\Row(2) {
id => 0
flag => "0"
}
Nette\Database\Row(2) {
id => 1
flag => "1"
}
Actual result:
--------------
Both PHP versions the same.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63244&edit=1