Incrementing a column value in CI |
[eluser]rupin[/eluser]
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'); $this->db->where("orgID",$lorgID); $this->db->update('organization'); } 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?
[eluser]umefarooq[/eluser]
you have to set it false right now you columen value is going as string to make it integer you have to do this Code: $this->db->set('createdForms', 'createdForms+1',FALSE); check user guide also http://ellislab.com/codeigniter/user-gui...ecord.html
|
Welcome Guest, Not a member yet? Register Sign In |