我有一个按钮,当单击该按钮时,它将通过 +1 更新一行。
它不起作用,它只会在数据库表中更新为 1,下次我单击它时它不会变为 2,它会保持在 1。我想要它,每次单击它都会将数字增加 1。
这是模型中的功能:
class Application_Model_DbTable_Row_User extends Sayka_Db_Table_Row_Abstract
{
public function grantDiscount()
{
$this->has_discount = has_discount + 1;
// $this->has_discount++; <- not working too, only increment to 1.
$this->save();
}
}
控制器:
if (isset($_POST['btn_buy_now']))
{
$user->grantDiscount();
}