根据在 cakephp 中选择的值向数据库添加多行

add multiple rows to database depending on value selected in cakephp

我的表格有每个月的输入复选框。

现在我正在尝试向数据库中添加多行。数据库行就像 Customername|Code|Month

选中“一月”、“三月”、“五月”和“七月”复选框时,应按如下方式添加值。

亚拉文|AM4298|一月;

亚拉汶|AM4298|三月;

亚拉文|AM4298|五月;

亚拉文|AM4298|七月;

cakephp 中的保存函数如何通过多行循环输入值。有人可以举例说明吗。

首先,您设置 Associations (may or may not be necessary in this case), then you make sure your <form> is created correctly via the FormHelper

最终结果是,当您 运行 对表单中发布的数据进行 saveAll() 时,它会将一组数据保存到多个数据库行中。