如何解决保存多个记录循环cakephp2
我想用此循环保存多个记录,但只保存最后一个项目。
foreach($pregunta['img'] as $key2 => $ima)
{
if(!empty($ima['name']))
{
$file['name'] = $ima['name'];
$file['svy_question_id'] = $newquestion['SvyQuestion']['id'];
$file['svy_survey_id'] = $newquestion['SvySurvey']['id'];
$file['dir'] = WWW_ROOT . DS . 'img\encuestas\img' . DS;
$file['video'] = 0;
if($this->SvyFiles->save($file))
{
debug($file);
$filename = basename($ima['name']);
$resul = move_uploaded_file($ima['tmp_name'],WWW_ROOT . DS . 'img\encuestas\img' . DS . $filename);
if(!$resul)
{
}
}
else
{
}
}
}
我使用cakephp2,我在cakephp3中知道我可以使用新实体,但是在cakephp2上我不知道该怎么做。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。