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)
發生了什麼事?這是教義中的錯誤嗎?