尝试使用 datamapper (Codeigniter) 将数据插入 Mysql 表时出现错误
Data truncated for column 'diameter' at row 1
INSERT INTO `purchases` (`bills_id`, `products_id`, `quantity`, `diameter`, `lena`, `lenb`, `lenr`, `thicka`, `thickb`, `widtha`, `widthb`, `boxes`, `resulta`, `resultb`) VALUES (1, 28, '2', '', '', '', '', '', '', '', '', '1', '', 2)
这是表格的屏幕截图
最佳答案
您正在尝试将空字符串 ''
插入到 double
中。
您不能将 string
存储在 double
列中。确保日期类型为 double
或兼容(int
、float
)
插入0
INSERT INTO `purchases` (`bills_id`, `products_id`, `quantity`, `diameter`, `lena`, `lenb`, `lenr`, `thicka`, `thickb`, `widtha`, `widthb`, `boxes`, `resulta`, `resultb`) VALUES (1, 28, '2', 0, '', '', '', '', '', '', '', '1', '', 2)
或
如果没有值,只需在查询中跳过它
INSERT INTO `purchases` (`bills_id`, `products_id`, `quantity`, `lena`, `lenb`, `lenr`, `thicka`, `thickb`, `widtha`, `widthb`, `boxes`, `resulta`, `resultb`) VALUES (1, 28, '2', '', '', '', '', '', '', '', '1', '', 2)
关于mysql - Mysql 上第 1 行第 'diameter' 列的数据被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47197844/