Home >Backend Development >PHP Tutorial >点赞 每点一次向数据库增加1

点赞 每点一次向数据库增加1

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:27:271540browse

这样子行不能,不知怎么写,求指点

<code>$num += 1;
$data['like_count'] = $num;
M('Weizhan')->where($map)->save($data);</code>

回复内容:

这样子行不能,不知怎么写,求指点

<code>$num += 1;
$data['like_count'] = $num;
M('Weizhan')->where($map)->save($data);</code>

你这样写不对滴!
M('weizhan')->where($map)->setInc('like_count',1);

参考 Redis 计数器

一般都不会数据库计数

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn