how to send 'bit' type data from HTML form to the database.
我们可以将它转换为 boolean 值或类似的东西吗?我尝试过使用 type='number'
但没有成功。我收到此错误:
... SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'active' at row 1 (SQL: insert into pg_vendor ...
此处的事件列的数据类型为bit
,为 0 或 1。
我也使用过 boolean 型、文本型、数字类型,但没有用。
我正在使用 Laravel 谢谢
最佳答案
您是否尝试过使用复选框或单选框:
$value = $request->input('bit') ? 1 : 0;
$bit = new Bit;
$bit->bit = $value;
$bit->save();
关于html - 如何将 'boolean'类型的数据从HTML表单发送到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46986900/