Home  >  Article  >  Backend Development  >  点评/投票/情绪类的功能什么机制限制会员只能投一次最省事

点评/投票/情绪类的功能什么机制限制会员只能投一次最省事

WBOY
WBOYOriginal
2016-06-13 12:05:11972browse

点评/投票/心情类的功能什么机制限制会员只能投一次最省事?
一些好像点评的系统,比如:文章下面,显示:好评/差评  这样的按钮

也就是像CSDN论坛的文章页面的...
对我有用[0] 丢个板砖[0] 

个人理解:
点一下经由AJAX/JQ这类发送去PHP操作MYSQL, 把好评/差评的字段+1

但是,一般这类的东,都是限制ip,甚至是只限cookie...

如果好评/差评的数据确有需要非常准确无水份

我是想用会员登入后才能点评(投票好差)的

那mysql 是否需要建议一个独立的点评表?

还有数据架构有什么比较好的方法,可以限制会员只能投一次?

请教一下各位,有什么好的建议?
------解决方案--------------------
建表是必须的,还不止一张
因为你还可能有 XX 关注了 XX、XX 是 XX 的好友等一系列的需求
需要综合考量
你现在思索的的是 SNS 网站的核心(或称基础)
------解决方案--------------------
参考下:

投票信息表:


CREATE TABLE `votes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(250) NOT NULL,
·uid· int(11) NOT NULL,
`vid` int(11) NOT NULL,
`fstcreate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8



文章表


CREATE TABLE `article` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`article_title` varchar(250) NOT NULL,
`article_type` int(11) NOT NULL,
`article_content` longtext NOT NULL,
`article_author` varchar(50) NOT NULL,
`article_click_count` int(11) NOT NULL DEFAULT '0',
`status` int(11) NOT NULL DEFAULT '0',
`likes` int(11) DEFAULT '0',
`unlikes` int(11) DEFAULT '0',
`fstcreate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`lastmodify` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `fulltext_article_title` (`article_title`,`article_content`,`key_words`)
) ENGINE=MyISAM AUTO_INCREMENT=119 DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='文章表'



如果限定登陆用户才可以投票,这样只要控制用户id和投票的主题id即可。
------解决方案--------------------
同一篇評論同一個用戶只能投一次就可以了。

表結構可以這樣
id
aid          評論id
mid         用戶id
addtime 發佈時間

select count(*) from table where aid=? and mid=? 判斷是否=1 來確定用戶是否可以再投這個評論。

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