简体   繁体   中英

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.

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. 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. I use PHP for this on my sites, though I've not done any speed tests myself...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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