php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63244 PDO fetch is inconsistent with MySQL's bit column
Submitted: 2012-10-08 23:03 UTC Modified: 2013-04-27 16:38 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: juzna dot cz at gmail dot com Assigned: vrana
Status: Closed Package: Documentation problem
PHP Version: 5.3.17 OS: Ubuntu
Private report: No CVE-ID:
 [2012-10-08 23:03 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-27 16:35 UTC] vrana@php.net
-Package: PDO related +Package: Documentation problem
 [2013-04-27 16:35 UTC] vrana@php.net
It's too late to fix this on the PHP level. Let me at least document it.
 [2013-04-27 16:37 UTC] vrana@php.net
Automatic comment from SVN on behalf of vrana
Revision: http://svn.php.net/viewvc/?view=revision&revision=330159
Log: Document mysqlnd incompatibility regarding bit data type (fix #63244)
 [2013-04-27 16:38 UTC] vrana@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: vrana
 [2013-04-27 16:38 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 16:02:22 2014 UTC