Welcome Guest, Not a member yet? Register   Sign In
Query returns 0 affected rows
#1

[eluser]CrossMotion[/eluser]
I have this strange problem, when I try to update an existing record codeigniter keeps returning 0 affected rows while records with the right content exist. the problem is in the weeknr. when I hard code it, it works. Do I need to add some ather kind of syntax to make it work?

below is the function in my model:

Code:
function add_item($input) {
    $this->db->where('userId',$input['userId']);
    $this->db->where('weeknr',$input['weeknr']);
    $this->db->update('cancelations_week',$input);

    if($this->db->affected_rows() == 0) {
        $this->db->insert('cancelations_week',$input);    
    }
}

And the code in my controller:

Code:
$this->load->model('afmelden_model');
$userId = $_SESSION['user_id'];
if ( $_SERVER ['REQUEST_METHOD'] == 'POST' ){
    for ($i = 0; $i <= 7; ++$i):
        $input['userId'] = $_SESSION['user_id'];
        $input['reservation'] = $this->input->post( 'week'.$i );
        $input['weeknr'] = $this->input->post( 'weeknummer'.$i );
        $this->afmelden_model->add_item($input);
    endfor;
}

Thx for the help!


Messages In This Thread
Query returns 0 affected rows - by El Forum - 02-23-2009, 09:37 AM
Query returns 0 affected rows - by El Forum - 02-23-2009, 09:55 AM
Query returns 0 affected rows - by El Forum - 02-23-2009, 09:55 AM
Query returns 0 affected rows - by El Forum - 02-23-2009, 10:40 AM
Query returns 0 affected rows - by El Forum - 02-23-2009, 10:43 AM
Query returns 0 affected rows - by El Forum - 02-24-2009, 06:18 AM
Query returns 0 affected rows - by El Forum - 02-24-2009, 06:33 AM
Query returns 0 affected rows - by El Forum - 02-24-2009, 07:18 AM
Query returns 0 affected rows - by El Forum - 02-24-2009, 12:16 PM
Query returns 0 affected rows - by El Forum - 03-04-2009, 05:10 AM
Query returns 0 affected rows - by El Forum - 03-04-2009, 08:29 AM
Query returns 0 affected rows - by El Forum - 03-07-2009, 10:33 AM
Query returns 0 affected rows - by El Forum - 03-07-2009, 10:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB