我有下表:
CREATE TABLE `Plot` (
`idPlot` int(11) NOT NULL,
`ListPrice` decimal(9,2) DEFAULT NULL,
`WebPrice` decimal(9,2) DEFAULT NULL,
`BottomPrice` decimal(9,2) DEFAULT NULL,
PRIMARY KEY (`idPlot`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
如果传递了一个空字符串,我希望在十进制字段中存储一个 NULL 值。但是,我似乎只能存储 0.00。
我正在使用 Meekrodb 进行更新:
$db->update('Plot', array(
'ListPrice' => $one['ListPrice'],
'BottomPrice' => $one['BottomPrice'],
'WebPrice' => $one['WebPrice']
), "idPlot=%s", $one['idPlot']);
我的输入数组如下所示:
Array
(
[idPlot] => 6
[ListPrice] => 99,999.00
[BottomPrice] =>
[WebPrice] =>
)
米克罗运行:
UPDATE `Plot` SET `ListPrice`='99999.00', `BottomPrice`='', `WebPrice`='' WHERE idPlot='6'
我得到:
Array
(
[0] => Array
(
[idPlot] => 6
[ListPrice] => 99999.00
[WebPrice] => 0.00
[BottomPrice] => 0.00
)
)
存储在数据库中。
有没有办法让它用 NULL 而不是 0.00 填充字段???
谢谢