Welcome Guest, Not a member yet? Register   Sign In
Active Record: add +1 to current value (update)
#1

[eluser]Razican[/eluser]
Hello, I'm getting crazy with this thing. I have a table where one value in one column should be updated t locck like current value +1 (or other number). The correct query would be something like this:
Code:
UPDATE `database`.`market` SET `amount` = `amount` +1 WHERE `market`.`id` = 1;

I have tried to do it via Active record and even with $this->db->query(); but with active record it crashes saying this in the error log:

Quote:DEBUG - 06-04-2011 19:20:26 --> DB Transaction Failure
ERROR - 06-04-2011 19:20:26 --> Query error: Incorrect integer value: '`amount` -4' for column 'amount' at row 1

And using $this->db->query(); I do not get the expected result as it puts the integer -4 in an unsigned bigint(20) field (18446744073709551611). What can I do?

Note: The crash report is done adding -4 value to current (120).


Messages In This Thread
Active Record: add +1 to current value (update) - by El Forum - 04-07-2011, 10:07 AM
Active Record: add +1 to current value (update) - by El Forum - 04-07-2011, 10:30 AM
Active Record: add +1 to current value (update) - by El Forum - 04-07-2011, 10:46 AM
Active Record: add +1 to current value (update) - by El Forum - 05-28-2011, 10:50 AM
Active Record: add +1 to current value (update) - by El Forum - 05-28-2011, 01:21 PM
Active Record: add +1 to current value (update) - by El Forum - 05-28-2011, 01:43 PM
Active Record: add +1 to current value (update) - by El Forum - 05-28-2011, 02:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB