I added a datime column to the table with a CURRENT_TIMESTAMP value, so that when adding and changing records, the time of the last changes is indicated. After adding a new record, everything works correctly, and after making changes, the date does not change. How can I fix it?

  • one
    Show the exact request to add (or DDL after adding). There is a suspicion. that DEFAULT is specified, but ON UPDATE is not. - Akina
  • @Akina public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', [ 'model' => $model, ]); } } public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', [ 'model' => $model, ]); } } public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', [ 'model' => $model, ]); } } - cruim
  • Well, actually it was assumed that we would see either the ALTER TABLE used, or the final SHOW CREATE TABLE. And what happens in PHP is not interesting to anyone and does not affect. - Akina
  • Solved a problem by setting the attribute on update CURRENT_TIMESTAMP - cruim

0