zend-framework2 - Zend/ZF2/TableGateway update() 如何处理这个 "hits = hits + 1"

标签 zend-framework2

我想写一个这样的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/

相关文章:

php - Zend Framework 2 - 添加表单类

mysql - 错误 e.rest apigility 如何创建数据库连接服务?

php - dompdf 不能在 zend 框架 2 中工作

zend-framework2 - 在 ZF2 中将组合和排序与表网关一起使用

mysql - 在 Zend 框架 2 的子查询中使用 limit 和 offset

php - Zend框架2 : Getting current controller name inside a module

php - ZF2 应用程序范围的 var(自定义唯一请求 id)

php - 如何检测 Zend Framework 2 应用程序是在控制台还是 HTTP 上下文中运行?

php - 使用控制台安装 Zend Framework 2

javascript - ZF2 : How to call a view helper in a service?