Welcome Guest, Not a member yet? Register   Sign In
$this->db->affected_rows() returns -1 after query
#3

[eluser]CroNiX[/eluser]
Also, if you are updating, affected_rows() will only return a positive number if the data actually changes. If it doesn't change, the update doesn't actually take place even thought the query is "successful".

So if the data was:
id:21
name:Bill

and you do an update setting the name to 'Bill' for id 21, no update will take place.

One thing you aren't checking, is the result of $update to see whether there was an error or not. It will return TRUE if the query was successfully run and FALSE if there was an error. Check for an error first before checking to see if the update had affected_rows().


Messages In This Thread
$this->db->affected_rows() returns -1 after query - by El Forum - 05-05-2012, 02:18 AM
$this->db->affected_rows() returns -1 after query - by El Forum - 05-07-2012, 12:23 AM
$this->db->affected_rows() returns -1 after query - by El Forum - 05-07-2012, 10:42 AM
$this->db->affected_rows() returns -1 after query - by El Forum - 05-08-2012, 05:30 AM
$this->db->affected_rows() returns -1 after query - by El Forum - 05-08-2012, 05:36 AM
$this->db->affected_rows() returns -1 after query - by El Forum - 05-08-2012, 06:57 AM
$this->db->affected_rows() returns -1 after query - by El Forum - 05-09-2012, 08:16 AM
$this->db->affected_rows() returns -1 after query - by El Forum - 05-10-2012, 01:35 AM
$this->db->affected_rows() returns -1 after query - by El Forum - 11-17-2013, 06:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB