我也想通过此查询更新多个值。但是当更新表然后更改文件名时,所有具有相同文件名的相同ID
这是我的职责
public function updateimgbyId($_FILES, $id){
for($i=0;$i<count($_FILES['file_img']['name']);$i++)
{
$filetmp = $_FILES['file_img']['tmp_name'][$i];
$filename = $_FILES['file_img']['name'][$i];
$filetype = $_FILES['file_img']['type'][$i];
$filepath ="media/".$filename;
if($filename=="" || $filetype==""){
$getmsg ="<script type='text/javascript'>alert('Please Insert Images...!')</script>";
return $getmsg;
}else{
move_uploaded_file($filetmp,$filepath);
$query = "UPDATE tbl_proimg
SET
file_img = '$filename',
path = '$filepath',
type = '$filetype'
WHERE productId = '$id'";
$initimg = $this->db->update($query);
if($initimg){
$getmsg ="<script type='text/javascript'>alert('Update')</script>";
return $getmsg;
}else{
$getmsg ="<script type='text/javascript'>alert('Not Insert Images')</script>";
return $getmsg;
}
}
}
}