Solar_Sql_Model_Record::increment()
Increments the value of a column immediately at the database and retains the incremented value in the record.
Parameters
(string)
$col
: The column to increment.(int|float)
$amt
: The amount to increment by (default 1).
Returns
(int|float) The value after incrementing. Note that other processes may have incremented the column as well, so this may not correspond directly with adding the amount to the current value in the record.
Description
Increments the value of a column immediately at the database and retains the incremented value in the record.
Incrementing by a negative value effectively decrements the value.
N.b.: This results in 2 SQL calls: one to update the value at the database, then one to select the new value from the database.
N.b.: You may have trouble incrementing from a NULL starting point. You should define columns to be incremented with a "DEFAULT '0'" so they never are null (although strictly speaking you do not need to define them as NOT NULL).
N.b.: This will not clear the cache for the model, since it uses direct SQL to effefct the increment. Thus, you will need to clear the cache manually if you want to the incremented values to show up from the cache.