yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.23k stars 6.91k forks source link

error beforeSave create UUID #19862

Closed atmanegara closed 1 year ago

atmanegara commented 1 year ago

What steps will reproduce the problem?

  1. code my model beforeSave

public function beforeSave($insert) { if($this->isNewRecord){ $this->myfieldKey = new \yii\db\Exception('UUID()'); return parent::beforeSave($insert); } }

image
  1. in controller save() image

get error

image

Additional info

Q A
Yii version 2.0.48.1
PHP version 8.1.9
Operating system win 11 (22H2)
samdark commented 1 year ago

You should use Expression, not Exception.