Yii2: update field with query builder

前端 未结 6 854
Happy的楠姐
Happy的楠姐 2021-01-07 17:26

How can I update field with query builder in Yii2? I can\'t find this in documentation.

Thanks!

UPD

This is the solution:

         


        
6条回答
  •  暖寄归人
    2021-01-07 17:43

    If you have mpre then one condition then use this

    $this->localdb->createCommand()
        ->update(
            $this->MYTable,
            [
                'name' => $el['new'],
                'data' => $el['data'],
            ],
            [
                'userId' => $this->user,
                'product_id' => $this->productId,
                'name' => $el['old'],
                'created' => $el['date'],
                'category' => $el['cat'],
            ]
    
        );
    

提交回复
热议问题