Welcome Guest, Not a member yet? Register   Sign In
Help required with Update statement
#1

[eluser]fusionblu[/eluser]
I am updating a row only if a certain column is null. I am using the null check in the SQL statement.
My statement is -
Code:
$query = $this->db->query("update t_temp_topics set verified_date=now() where id=10 and token='mytoken' and verified_date is null");

I need to check how many rows ( 1 or 0) were updated and perform some actions. In the above case the result ($query) is always 1 even if the update statement did not update any rows.
How do I check for 'no rows updated' condition ?
Thanks.
#2

[eluser]gtech[/eluser]
I think you can do
Code:
$numrows = $this->db->affected_rows();
after the update.

the $query variable in your case just tells you if there was an sql error (1 being no error even if nothing updated).
#3

[eluser]fusionblu[/eluser]
Thanks. it worked.




Theme © iAndrew 2016 - Forum software by © MyBB