2017-07-24 3 views
0

Die Abfrage wäre update table1 set id=id+1 where id>=10 and staff_id=$staff_id.yii2 updateallcounter mit 2 Bedingungen

Mit nur einzelne Bedingung kann ich

schreiben

\common\models\leave\table1::updateAllCounters(['id' => 1], ['>', 'id', 10]);

Wie die hinzuzufügen, wo staff_id=$staff_id?\common\models\leave\table1::updateAllCounters(['id' => 1], ['>', 'id', 10],['staff_id'=>$staff_id]); aber ohne Erfolg versucht.

Antwort

4

Sie können Bedingungen schaffen, wie unter

$condition = ['and', 
    ['>', 'id', 10], 
    ['=', 'staff_id',$staff_id], 
]; 

und aktualisieren Sie Ihre Abfrage

\common\models\leave\table1::updateAllCounters(['id' => 1],$condition); 
Verwandte Themen