计数匹配数 [英] Count number of hits

查看:119
本文介绍了计数匹配数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发简单的cms应用程序。



我想集成一些记录的匹配数,所以当查看记录时浏览器,表中的hits字段应该更新为1。



在控制器中,我尝试:



$ data = array('Publication'=> array('hits'=>'hits + 1'));

$ this-> publication-> save($ data);



...但没有运气,因为蛋糕tryes更新字段 hits p>

可以告诉我我在哪里错了,以及如何增加字段 hits 的更新。



提前谢谢!

解决方案

确定,我解决了

  $ this-> Publication-> updateAll(array('Publication.hits'="'Publication.hits + 1'),array 'publication.id'=> $ id)); 


i'm developing simple cms application.

i want to integrate "number of hits" for some of the records, so when view of the record is showed in browser, hits field in table should be updated by 1.

in controller, i tryed with:

$data = array( 'Publication' => array( 'hits' => ' hits + 1') );
$this->Publication->save( $data );

... but no luck, since cake tryes to update field hits with value hits + 1.

can you tell me where i'm wrong, and how to incrementaly update field hits.

thank you in advance!

解决方案

ok, i solved it

$this->Publication->updateAll(array('Publication.hits'=>'Publication.hits+1'), array('Publication.id'=>$id));

这篇关于计数匹配数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆