Yii2: update field with query builder

前端 未结 6 820
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:59

    Create command can be used directly as follows :

    \Yii::$app->db->createCommand("UPDATE table SET column1=:column1, column2=:column2 WHERE id=:id")
    ->bindValue(':id', your_id)
    ->bindValue(':column1', :column1_value)
    ->bindValue(':column2', :column2_value)
    ->execute();
    

提交回复
热议问题