Welcome Guest, Not a member yet? Register   Sign In
how to check if a row is update
#5

[eluser]Cristian Gilè[/eluser]
[quote author="lennierb5" date="1295148732"]I thought that if

Code:
$this->db->affected_rows() == 0 // Update query was ran successfully but nothing was updated
$this->db->affected_rows() == 1 // Update query was ran successfully and 1 row was updated
$this->db->affected_rows() == -1 // Query failed

So you should be able to check for 1 if you want to know if anything has been updated.[/quote]
Your assumption is not true. Here, an example:
Code:
$this->db->where('id',27);
$this->db->update('my_table',$some_data);

If id=27 doesn't exist the query doesn't fail and the return value for affected_rows is 0.


Cristian Gilè


Messages In This Thread
how to check if a row is update - by El Forum - 01-15-2011, 12:23 PM
how to check if a row is update - by El Forum - 01-15-2011, 12:43 PM
how to check if a row is update - by El Forum - 01-15-2011, 02:54 PM
how to check if a row is update - by El Forum - 01-15-2011, 03:32 PM
how to check if a row is update - by El Forum - 01-15-2011, 03:46 PM
how to check if a row is update - by El Forum - 01-15-2011, 10:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB