我想保存记录,但是在for循环中,下一个id为null,我如何在这种情况下保存记录,当找到null并保存以前的记录时,循环将停止。
foreach($record['ProductPlan'] as $value=>$key)
{
$ProductsUser = array('product_plan_id'=>$key,'user_node_id'=>$userNodeId, 'is_active'=>1);
$this->$model->UserNode->ProductPlansUserNode->create();
$this->$model->UserNode->ProductPlansUserNode->save($ProductsUser);
}
并且错误是违反完整性约束:1048 Column 'product_plan_id' cannot be null
and in the array
'2'
array(
'product_plan_id' => '2',
'user_node_id' => '26',
'is_active' => (int) 1
)
'3'
array(
'product_plan_id' => '3',
'user_node_id' => '26',
'is_active' => (int) 1
)
'' // This is null how can i save previous records before null?