array(
'Student' => array(
'student_name' => array(
(int) 0 => '14',
(int) 1 => '17',
(int) 2 => '18'
),
'fee_name' => array(
(int) 0 => '1',
(int) 1 => '1',
(int) 2 => '1'
),
'standard_name' => array(
(int) 0 => '1',
(int) 1 => '1',
(int) 2 => '1'
),
'section_name' => array(
(int) 0 => '7',
(int) 1 => '7',
(int) 2 => '7'
),
'day_name' => array(
(int) 0 => '2015-04-23',
(int) 1 => '2015-04-23',
(int) 2 => '2015-04-23'
),
'feeplan_name' => array(
(int) 0 => '4',
(int) 1 => '4',
(int) 2 => '4'
)
)
)
我想将以下数组代码更改为 cakephp saveAll()适用的格式。我的英语对于提前知道的事情有点弱。
答案 0 :(得分:0)
查看saveMany
修改强>
你的HTML应该看起来像这样
<input type="text" name="data[Student][0][student_name]">
<input type="text" name="data[Student][1][student_name]">
<input type="text" name="data[Student][2][student_name]">
<input type="text" name="data[Student][0][fee_name]">
<input type="text" name="data[Student][1][fee_name]">
<input type="text" name="data[Student][2][fee_name]">
那么你的数组将是
array(
'Student' => array(
(int) 0 => array(
'student_name' => '',
'fee_name' => ''
),
(int) 1 => array(
'student_name' => '',
'fee_name' => ''
),
(int) 2 => array(
'student_name' => '',
'fee_name' => ''
)
)
)
你会打电话给
$this->Model->saveMany($this->request->data['Student']);