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
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';}