In MySQL there are also functions. For example DAY(), ASCII(), DATEDIFF(), and so on, a lot of function. So it is possible to make complicated queries using these functions. And all computing/manipulation with data will be done still in MySQL by MySQL functions. And I can get the result of my query in PHP already prepared by MySQL as refined as only possible.
But it’s also possible to compute/manipulate data from DB using PHP function. I mean, I retrieve data from DB using as simple SQL query as possible, then get it into an array, fetch that array into variables and only now, using PHP functions, begin necessary manipulations with my data to refine what I need.
So my question which way is better to work with DB? Should I use MySQL’s sever strength as full as only possible to get as ready-to-use data as only possible, or should I use more PHP functions to manipulate raw data from DB?
If you use MySQL (or other non-distributed databases) you might consider doing this in code. This will lighten the load on the database server while webservers are perfectly scalable these days. You only have 1 MySQL server, and can scale up to X webservers.
The best would be to create a helper class that wraps the database native functions.
If you leave the performance issues for what they are, it would always be better to use available functions instead of creating them yourself.