For instance, say I have a data structure with two integer columns start and end, but I\'m actually interested in the start and difference between
I would classify "$end - $start" as business logic, and that belongs in the model layer not the persistence layer. That means performing the calculation in PHP. This has a number of benefits:
If you change databases later, you don't need the same operators to exist.
You can source control the logic that performs the calculation.
You can more thoroughly unit test.