UPDATE我在学说提出了错误这个http://www.doctrine-project.org/jira/browse/DC-400PHP - Doctrine ORM无法正确处理bit(1)类型?
我有以下Doctrine模式:
---
TestTable:
columns:
bitty: bit(1)
我已经创造了这个数据库和表。然后,我有下面的PHP代码:
$obj1 = new TestTable();
$obj1['bitty'] = b'0';
$obj1->save();
$obj2 = new TestTable();
$obj2['bitty'] = 0;
$obj2->save();
显然,我的尝试是保存在bitty
列的位值0
。
但是运行此PHP代码,我得到以下奇怪的结果后:
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)
那些箱子是0x01
字符,即学说的值设置为1,不是0
不过,我可以将0直接从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)
发生了什么事?这是教义中的错误吗?