当给AR写beforeSave方法时,注意返回true还是false。如果没有返回值,或者返回false,那么就不会存入数据库。如下

Yii2 ActiveRecord save失败

晚上写代码的时候beforeSave忘了返回true,导致无法存入数据。

Yii2 ActiveRecord save失败

 

操作完后return true。就可正常存入了。

http://www.yiichina.com/doc/api/2.0/yii-db-baseactiverecord#beforeSave()-detail

相关文章:

  • 2021-08-27
  • 2022-12-23
  • 2021-07-24
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2021-04-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案