increment & decrement in query builder

problem described here http://www.yiiframework.com/forum/index.php?/topic/24045-incrementing-and-decrementing-via-query-builder/

increment in query builder should be simple like update, or it not worth it




Yii::app()->db->commandBuilder->createUpdateCommand( 

                '{{table}}', 

                array( 

                    'counter' => new CDbExpression( 'counter + :counter' , array(':counter'=>1))

                    ), 

                new CDbCriteria(array(

                    "condition" => "id = :id" , 

                    "params" => array(

                        "id"=>1

                    )

                ))

            )->execute();



query builder rocks ;D

it makes our live easy, and our queries “short” :lol:

There is a shoter way:


User::model()->updateCounters(['points'=>$this->points], 'id=:id',[':id'=>$this->id]);