我想插入多条记录。这是我的 ci=ontroller 代码:
if(empty($this->data) == false)
{
for($i=0;$i<=count($this->data['Breakdown']);$i++)
{
echo count($this->data['Breakdown']);
$this->Breakdown->create();
if($this->Breakdown->save($this->data))
{
$this->Session->setFlash('Quantity Breakdown has been added Successfully.', 'default', array('class' => 'oMsg1 oMsgError1'));
//$this->redirect('qty_breakdown');
}
}
}
else
{
$this->set('errors', $this->Breakdown->invalidFields());
}
我的问题是,如果我在文本字段中只输入一个值,它会插入记录八次。我想要一个解决方案来使用此代码完美地插入它?