为foreach()提供的参数无效

时间:2016-10-31 07:32:00

标签: codeigniter

我不明白如何修复此代码:

where city='$_GET['city']'

我尝试了多个代码,例如将其更改为return $this->db->update('slideshow'); $query等,但错误仍然存​​在。我仍然需要使用$query_result

控制器/ Cuploadfile.php

$this->db->update('');

模型/ Mpages.php

function uploadedit()
{

    $data['images'] = ''; // Need to place it here and get images here.

    //set preferences
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'jpg|gif';
    $config['max_size']    = '500000';

    //load upload class library
    $this->load->library('upload', $config);
    $this->load->model('Mpages');


    if (!$this->upload->do_upload('filename'))
    {
        // case - failure
        $upload_error = array('error' => $this->upload->display_errors());
        $this->load->view('addslideshows', $upload_error);
    }
    else
    {
        // case - success
        $upload_data = $this->upload->data();           
        $filename = $upload_data['file_name'];
        $image_id = $this->uri->segment(3);

        $data['images'] = $this->Mpages->edit_slideshow($filename, $image_id);

        $data['success_msg'] = '<div class="alert alert-success text-center">Your file <strong>' . $upload_data['file_name'] . '</strong> was successfully uploaded!</div>';
        $this->load->view('editslideshows', $data);
    }
}

2 个答案:

答案 0 :(得分:0)

将您的模型功能更改为此

public function edit_slideshow($filename, $image_id){
    $this->db->where('image_id', $image_id);
    $this->db->update('slideshow', $filename);

    if($this->db->affected_rows() > 0){
       return true;
    }else{
       return false;
    }
}

答案 1 :(得分:0)

重写你的模型

public function edit_slideshow($filename, $image_id)
{   
$this->db->set('slideshow_image', $filename);
$this->db->where('image_id', $image_id);
$update=$this->db->update('slideshow');
if($update)
{
  return true;
}
  return false;
}