For example (not verbatim)
/**
@Entity
*/
class Event
{
/**
@Column
*/
protected $time_start;
/** .. */
protected $time_end;
/** getters, setters, etc */
/** @return duration of event as a string, non-table function */
public function getDuration() { ... }
}
Or should the ORM just be the table, and nothing more?
This could be a subjective view, as everyone has their own opinions, but in programming there and things you do and things you really shouldn’t do. I was just wondering if this is one of those cases.
Not, it is not a good idea. If nothing else, would be violating Single responsibility principle.
If you are making an ORM, your instances should deal only with data storage/retrieval. In your example
getDuration()is part of domain business logic and should reside within domain objects.Basically, what you are dealing here is the difference between data mapper and active record patterns. And, if you are trying to write code that adheres to SOLID principles, one would consider active record to be an antipatter, which in long term causes unmitigated technical debt.