简体   繁体   English

视图与页面计算

[英]Views vs. in page calculations

Ok I wanted to get the communities thoughts on the use of Views in MYSQL vs. in page calculations using php. 好的,我想让社区对在MySQL中使用视图与在使用PHP的页面计算中使用视图的想法。

I am about to start trying to design a page which relies on retrieving data from my database and working out averages and totals based on the data it retrieves. 我将开始尝试设计一个页面,该页面依赖于从数据库中检索数据并根据所检索的数据得出平均值和总计。 My initial thoughts were that I should retrieve it in the normal way as if I were going to display each record and then calculate the averages and totals in php before displaying. 我最初的想法是,我应该以正常的方式检索它,就像我要显示每条记录,然后在显示之前计算php中的平均值和总数。 However before I go to the trouble and no doubt hours of tinkering that it will take for an amateur like me to get it working, I wanted to know if it may well be worth setting up a view instead and just retrieve the information from that with a simple select command? 但是,在我麻烦解决这个问题之前,毫无疑问,需要花很多时间来修补像我这样的业余爱好者才能使它正常工作,我想知道是否值得设置一个视图,而只是从中检索信息。一个简单的选择命令?

The data that it will be working the avergaes and totals out for is updated weekly and in an ideal world I would want my averages and total to be year to date until the end of the first year, at which point a total will continue running but a new year to date would commence. 每周将更新将要使用平均值和总计的数据,在理想情况下,我希望我的平均值和总计一直是年初至今,直到第一年年底为止,此时总计将继续运行,但是迄今为止,新的一年将开始。

Any ideas or suggestions would be great. 任何想法或建议都很好。

Alan. 艾伦

I would think it is faster to let PHP do the calculations. 我认为让PHP进行计算更快。 I use PHP for this on my sites, though I've not done any speed tests myself... 我在自己的网站上为此使用了PHP,尽管我自己尚未进行任何速度测试...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM