column does not obey the where statement of an update

3

I have a problem. At the moment I do an update, when I use the where only the line with the informed code is updated. but the description field that I inform, its contents is replicated for all the lines of the bank this is the only column that this occurs. I'm using php with codeigniter

Following the form:

            <h3> Descrição:</h3>
            <div class="form-group">
                <textarea name="descricao" id="texto">
                    <?php echo $evento[0]->cal_descricao ?>  
                </textarea>
            </div>

The update function follows:

public function editar($id) {
    $data['cal_descricao'] = $this->input->post('descricao');
    $this->db->set('cal_descricao', $this->input->post('descricao'));
    $this->db->set('cal_titulo', $this->input->post('titulo'));
    $this->db->set('cal_estado', $this->input->post('estado'));
    $this->db->set('cal_pais', $this->input->post('pais'));
    $this->db->set('cal_dataEvento', $this->input->post('inicio'));
    $this->db->set('cal_dataTermino', $this->input->post('termino'));
    $this->db->set('cal_modalidades', $this->input->post('modalidades'));
    $this->db->where('cal_cod', $id);
    $this->db->update('v1_calendario');
    if ($this->db->update('calendario', $data)) {           
        $this->load->view('calendario/index');
        redirect('calendario/index');
    } else {
        redirect('calendario/index');
    }
}

html output from table:

 <tbody>
                 <tr>
                    <td>Evelinsss</td>
                    <td><p>vida</p></td>
                    <td>RJ Brazil</td>
                    <td>2016-06-05</td>
                    <td>2016-06-20</td>
                    <td>27</td>
                    <td><a href="http://localhost:8080/WAS/site/controle/calendario/atualizar/1">
                            <button type="button" class="btn btn-primary">Atualizar</button>
                        </a>
                    </td>

                </tr>
                                <tr>
                    <td>Evelin</td>
                    <td><p>vida</p>

                        RJ Brazil                         2016-06-05                         2016-06-20                         27                                                                                       Update                                                                           

The update of the line only the title of line one has been modified, but the description (result: life), occurs in the bottom line too.

    
asked by anonymous 09.06.2016 / 16:29

1 answer

2

I was able to solve it! the problem was the update before the if:

 public function editar($id) {
    $data['cal_descricao'] = $this->input->post('descricao');
    $this->db->set('cal_descricao', $this->input->post('descricao'));
    $this->db->set('cal_titulo', $this->input->post('titulo'));
    $this->db->set('cal_estado', $this->input->post('estado'));
    $this->db->set('cal_pais', $this->input->post('pais'));
    $this->db->set('cal_dataEvento', $this->input->post('inicio'));
    $this->db->set('cal_dataTermino', $this->input->post('termino'));
    $this->db->set('cal_modalidades', $this->input->post('modalidades'));
    $this->db->where('cal_cod', $id);
    //        $this->db->update('v1_calendario'); - Removi essa linha
    if ($this->db->update('calendario', $data)) {           
        $this->load->view('calendario/index');
        redirect('calendario/index');
    } else {
        redirect('calendario/index');
    }
}
    
09.06.2016 / 16:48