更新时间:2023-11-19 17:26:46
这里的问题是 $seller
不是一个真正的"属性(Yii 通过使用魔法 __get
方法),因此实际上您正在尝试修改函数的返回值(无效).就好像你试图这样做:
The problem here is that $seller
is not a "real" property (Yii implements properties on its Models by using the magic __get
method), so in effect you are trying to modify the return value of a function (which has no effect). It is as if you tried to do:
function foo() {
return 42;
}
// INVALID CODE FOR ILLUSTRATION
(foo())++;
我不确定此行为在不同 PHP 版本上的状态,但您可以使用一个简单的解决方法:
I 'm not sure about the status of this behavior on different PHP versions, but there is an easy workaround you can use:
$seller = $this->seller;
$seller->current_item++;
$seller->wins++;
$seller->save();