1

I want to make a poll system into my website like http://dilemmaplugin.com/, this is what I want but is just for Wordpress...

I don't know if there is some plugin for Symfony2, I've searched but nothing... So I would like to ask you a walkthrough about how to make it, using caché/ip for not voting twice... This is where I'm lost, the vote is basic, I think:

Database would be like

id     question              option_a       option_b
1      PS4 or Xbox One?      1523           1102

So if you press the two buttons, option fields will do +1, easy as ABC, but what about the caché/ip preventing duplicate votes?

I was also thinking about making some carousel div that contains random votes when you press next but that can be done via Json I think, just querying the DB with Ajax...

Thank you

4

1 回答 1

2

如果您想/需要坚持当前的模式,防止 IP 地址重复投票的一种方法是您可以使用memcached之类的东西(非常快),并为每个投票存储问题 ID 和 IP 地址。如果您使用 Doctrine 作为您的 ORM,那么您可以使用preUpdateEvent来检查 IP 地址是否存在。

您可以在您的实体上设置自定义验证约束以检查 IP 地址,这有助于向您的表单显示友好的消息。

另一种可能性是在您的控制器或模型管理器中设置一个事件侦听器来检查 IP 地址。

希望这能让你朝着一个不错的方向前进。

于 2013-12-27T22:34:17.453 回答