如何根据我的条件更新所有记录? (我的代码不起作用)
$condition[] = ['>','position',$old_position]; $condition[] = ['<=',$new_position]; $condition[] = ['in','id',$ids]; Video::updateAll([ 'position' => new \yii\db\Expression('@a := @a + 1'),],$condition);
你忘记了运算符,你应该试试:
原文链接:https://www.f2er.com/php/135760.html$condition = ['and',['>',$old_position],['<=',$new_position],['in',$ids],];
阅读更多 :
http://www.yiiframework.com/doc-2.0/yii-db-query.html#where()-detail