Welcome Guest, Not a member yet? Register   Sign In
Incrementing a column value in CI

I have been trying to increment the count of a column in a table using the active record class.
Here is the code existing in my model

function increment_form_count($lorgID)
$this->db->set('createdForms', 'createdForms+1');


When I lookup the MySQL logs the query that gets generated is

UPDATE `organization` SET `createdForms` = 'createdForms+1' WHERE `orgID` = '4'

The query looks OK, but the value in the DB has not incremented.

The type of column 'createdForms' is an INT type.

When I run the same query from phpmyadmin, the value gets updated.

Do i need to manually commit the transaction, since the value does not increment from code?

you have to set it false right now you columen value is going as string to make it integer you have to do this

$this->db->set('createdForms', 'createdForms+1',FALSE);

check user guide also


Thanks umefarooq...

Theme © iAndrew 2016 - Forum software by © MyBB