I try update num_of_gifts without select use yii active record and CDbCriteria
this is my code:
$attributes = array('num_of_gifts' => 'num_of_gifts'+1);
$condition = 'bla bla';
$params = array(bla bla);
Gifts::model()->updateAll($attributes, $condition, $params);
all I get that “1” at the num_of_gifts cell,
is it possible increase 1 to num_of_gifts? or I need select the amount of num_of_gifts and after it use update?
If you are just updating counters you could use Yii’s updateCounters method.
Example for updating all:
That method takes a condition to update a specific record, but if you don’t include a condition it will update all records.
[edit]
If you want to update selected records based on a condition, the format is this: