Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Schema Files
-
Labels:None
-
Environment:Ubuntu 9.10 php 5.2 mysql 5.1, all installed with ubuntu's apt
Description
Ihave the following Doctrine schema:
—
TestTable:
columns:
bitty: bit(1)
I have created the database and table for this. I then have the following PHP code:
$obj1 = new TestTable();
$obj1['bitty'] = b'0';
$obj1->save();
$obj2 = new TestTable();
$obj2['bitty'] = 0;
$obj2->save();
Clearly my attempt is to save the bit value 0 in the bitty column.
However after running this PHP code I get the following odd results:
mysql> select * from test_table;
---------+
| id | bitty |
---------+
| 1 | |
| 2 |
---------+
2 rows in set (0.00 sec)
mysql> select * from test_table where bitty = 1;
---------+
| id | bitty |
---------+
| 1 | |
| 2 |
--------+
2 rows in set (0.00 sec)
mysql> select * from test_table where bitty = 0;
Empty set (0.00 sec)
Those boxes are the 0x01 character, i.e. Doctrine has set the value to 1, not 0.
However I can insert 0's into that table direct from MySQL:
mysql> insert into test_table values (4, b'0');
Query OK, 1 row affected (0.00 sec)
mysql> select * from test_table where bitty = 0;
---------+
| id | bitty |
---------+
| 4 |
---------+
1 row in set (0.00 sec)
See also this question on StackOverflow http://stackoverflow.com/questions/2008021/php-doctrine-orm-not-able-to-handle-bit1-types-correctly