Can't update row in database

Hi,
I’m new here an i have a problem with udating my database.
I’ve tried it with ActiveRecord and I even tried it by creating an Sql command.
please tell me where I’m wrong :disappointed_relieved:

SQL_Command:

             $test=Yii::$app->db->createCommand('UPDATE `timetable` SET `status`= :status, `bookingID` = :bookingID WHERE `field`= :field AND `id`= :id')
        ->bindValue(':bookingID', $this->_id)
        ->bindValue(':field', $field)
        ->bindValue(':id', $id)
        ->bindValue(':status', 'status');
         $test->queryOne();

Active Record:

        $model = Timetable::find()->where(['id'=> $id, 'field'=>$field])->one();
        $model->status = $status;
        $model->bookingID = $id;
        if($model->save()){
        echo 'update successfull';
        }else{echo'update failed';}

you should probably use $test->execute() instead of query.

if this shows 'update failed' you probably have validation errors, use ->save(false) to skip validation, or print_r($model->getErrors()); to show validation errors.

See https://www.yiiframework.com/doc/guide/2.0/en/input-validation

You might need to ensure the field has a rule in it. Otherwise you can always use $model->save(false) to ignore validation.