Simply said, I am trying to do this:
$widgetsUsed->updateAll(array(
'position'=>'- 1'
),
"position > {$position} AND sidebar_id = {$sidebar_id}"
);
Does anyone have a clue if this works, or give some other suggestions how to achieve this?
Having a hard time to debug this since I can't exactly make up what values are chaning when in my database. So I was hoping anyone here would directly know how to do this.
Thanks in advance
You can try as below
Yii::app()->db->commandBuilder->createUpdateCounterCommand('{{myTable}}', array(
'position' => 1, // -1 for decrementing
new CDbCriteria(array(
"condition" => "position > :pos AND sidebar_id = :id",
"params" => array(
"pos"=>$position,
"id"=>$sidebar_id
)
))
));
If you have higher version of Yii
, then you can use http://www.yiiframework.com/wiki/282/using-counters-with-activerecord/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.