我想写一个这样的sql:
"Update tablename SET hits = hits + 1 WHERE id = $id"
在zf2中,我们使用了TableGateway,我写的代码:
$this->tablenametableGateway->update(array(
'hits' => new Expression('hits + 1')),array(
'id' => $id)
);
但结果是错误的,例如:
第一次命中等于1,刷新页面后,命中等于3,每次增加2,不增加1。
我不知道如何解决这个问题,需要你的帮助,谢谢!
最佳答案
我解决了这个问题。我安装了 Chrome 扩展程序“Web Server Notifier”,这个扩展程序会导致 chrome 访问当前页面的 2 倍,非常快!关闭扩展后,我的代码运行良好!
关于zend-framework2 - Zend/ZF2/TableGateway update() 如何处理这个 "hits = hits + 1",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16050908/