Yii2: update field with query builder

前端 未结 6 819
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:37

     Yii::$app->db->createCommand()
             ->update('customer', ['otp' => $otp_rand], ['custid' => 23])
             ->execute();
    

    **this is the right syntax and works & tested in yii2 **

提交回复
热议问题