存储每日页面浏览量以及总计数的最有效方法 [英] Most efficient way of storing daily page views, as well as a total count

查看:328
本文介绍了存储每日页面浏览量以及总计数的最有效方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于在数据库中存储文章或视频的页面浏览量的讨论,但是我似乎找不到关于存储每日页面浏览量的任何信息.例如,DeviantArt会显示过去15天左右的时间,以及每个人在一张小图中获得多少网页浏览量,以及个人资料的总网页浏览量.

There allot of discussion on storing page views for an article or video in a database, but I can't seem to find any information on storing daily page views. For example DeviantArt shows you the past 15 or so days and how many page views each one got in a little graph, as well as the total page view for the profile.

您可以在上面准确地看到我想要达到的目标,DeviantArt可以在他们获得数百万点击的情况下进行大规模的开发.

You can see above exactly what I'm trying to achieve, and DeviantArt do it on a huge scale as they get millions of hits.

我正在PHP和MySQL上使用CodeIgniter

I am using CodeIgniter on PHP and MySQL

推荐答案

您每天可以排一行,然后在查看时增加计数.

You could have a row for each day then increment the count when it is viewed.

INSERT INTO views (day,views) VALUES (CURDATE(),1) ON DUPLICATE KEY UPDATE views=views+1;

还有一个PHP脚本...

And a PHP script...

mysql_query("INSERT INTO views (day,views) VALUES (CURDATE(),1) ON DUPLICATE KEY UPDATE views=views+1;");

这使用一个名为视图"的表以及两行天"和视图".

This uses a table called 'views' and 2 rows 'day' and 'views'.

有关更多信息,请参见本文.

See this article for more information.

这篇关于存储每日页面浏览量以及总计数的最有效方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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