Welcome Guest, Not a member yet? Register   Sign In
duplicates when using database update


I have a strange issue here.

can't find anything about it on google or the forum and first time i got this problem with CI.

When i update one of my post from my MySQL DB it makes a duplicate of it and add a new row, it does not take all the info because i don't need to change that.

my code is this

function edit($options = array(), $site, $edit = FALSE)
     $db = $this->__dataaseConnection($site);
     $query = $db->get_where('news', array('id'=> $options['id']));
     return $query->result();
     $data = array(
    'headline' => $options['headline'],
    'text' => $options['text'],
    'status' => $options['status']
     $db = $this->__dataaseConnection($site);
     $db->update('news', $data, array('id' => $id));
     redirect('/news/list_entries/' . $site);

function edit()
$options = array(
   'headline' => $this->input->post('headline'),
   'text' => $this->input->post('text'),
   'status' => $this->input->post('status'),
   'id' => $this->uri->segment(4)

$data['current_view'] = 'news_view';
$data['news'] = $this->news_model->edit($options, $this->uri->segment(3), FALSE);

$this->form_validation->set_rules('headline', 'Headline', 'required');
$this->form_validation->set_rules('text', 'Text', 'required');

if($this->form_validation->run() == TRUE)
     $data['news'] = $this->news_model->add($options, $this->uri->segment(3), TRUE);
$this->load->view('includes/template', $data);

my form is looking like this.

don't ask about the language, its danish.

when i edit that 3 fields i get this output

i edit the post with ID 3, and it make a new row of that post..

another database update is working just fine.

Messages In This Thread
duplicates when using database update - by El Forum - 10-01-2011, 07:38 PM

Theme © iAndrew 2016 - Forum software by © MyBB